Roblox: Difference between revisions

From Virtujoy Documentation
Created page with "* [https://create.roblox.com/dashboard/creations https://create.roblox.com/dashboard/creations] * [https://create.roblox.com/settings/eligibility/public-publish https://create.roblox.com/settings/eligibility/public-publish] * [https://create.roblox.com/docs/reference/engine/libraries/task] <syntaxhighlight lang="lua" line> local RunService = game:GetService("RunService") local Character = script.Parent.Parent local HumanoidRootPart = Character:FindFirstChild("HumanoidR..."
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
* [https://create.roblox.com/settings/eligibility/public-publish https://create.roblox.com/settings/eligibility/public-publish]
* [https://create.roblox.com/settings/eligibility/public-publish https://create.roblox.com/settings/eligibility/public-publish]


* [https://create.roblox.com/docs/reference/engine/libraries/task]
== Task and heartbeat ==
* [https://create.roblox.com/docs/reference/engine/libraries/task https://create.roblox.com/docs/reference/engine/libraries/task]


<syntaxhighlight lang="lua" line>
<syntaxhighlight lang="lua" line>
Line 19: Line 20:
end)
end)
</syntaxhighlight>
</syntaxhighlight>
== Team ==
* [https://create.roblox.com/docs/reference/engine/classes/Team https://create.roblox.com/docs/reference/engine/classes/Team]
<syntaxhighlight lang="lua" line>
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)
</syntaxhighlight>
== Place ==
* [https://www.youtube.com/watch?v=V2iMbyidODo https://www.youtube.com/watch?v=V2iMbyidODo]

Latest revision as of 07:08, 9 February 2026

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)

Place