Roblox

From Virtujoy Documentation
Revision as of 06:19, 9 February 2026 by Timothy (talk | contribs)

Task and heartbeat

local RunService = game:GetService("RunService")
local Character = script.Parent.Parent
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local pet = script.Parent

local function SetPetCFrame()
	pet.PrimaryPart.CFrame = HumanoidRootPart.CFrame * CFrame.new(2, 2, -3)
end -- Hroot is player's HumanoidRootPart

RunService.Heartbeat:Connect(function()
	wait()
	SetPetCFrame()
end)

Team

local Players = game:GetService("Players")

local function onPlayerAdded(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local playerScore = Instance.new("IntValue")
	playerScore.Name = "Score"
	playerScore.Value = 0
	playerScore.Parent = leaderstats
end

Players.PlayerAdded:Connect(onPlayerAdded)