Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I need help with PlayerAdded and stuff?

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)

2 comments

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!

0

Also check out CharacterAdded, it's an event of Player that fires when the Character Spawns/Respawns.

1 answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.