Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need help with PlayerAdded and stuff?

Asked by 8 years ago
Edited 8 years ago

I have a script that moves a crystal above a players head, but I don't know how to make it so when a player joins the game he gets his own crystal that follows him. This is in a local script btw. Also, looking for developers for my game. If you are interested contact me on Roblox. My Username is KuroNakamura.

function MoveCrystal()
    local character = game.Players.LocalPlayer.Character
    local crystal = workspace.Crystal
    local head = character["Head"]
    local objectSpace = CFrame.new(0, 2, 0)
    local worldSpace = head.CFrame:toWorldSpace(objectSpace)
    crystal.CFrame = worldSpace

end

game:GetService('RunService').RenderStepped:connect(function()
    MoveCrystal()
end)

0
Do NOT use local scripts to move objects in workspace or do other server-sided jobs. It won't work well. The wiki has a really good page on PlayerAdded. Check it out! EzraNehemiah_TF2 3552 — 8y
0
Also check out CharacterAdded, it's an event of Player that fires when the Character Spawns/Respawns. EzraNehemiah_TF2 3552 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

This is what I have been doing.

game.Players.PlayerAdded(function(plr)
--stuff
--even more stuff
end)

So when a player joins, it will do whatever is underneath the thing. Hope this helps!

Ad

Answer this question