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

Players not spawning in correct place after respawning?

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:FindFirstChild("HumanoidRootPart").CFrame = SpawnValues[math.random(1, #SpawnValues)]
	end)
end)

(SpawnValues is a table with the cframes of certain parts I want the player to spawn at) This script works fine in roblox studio, but in game it doesn't work? I don't want to use a spawnlocation part since I want the player when they join to spawn in the lobby, then later for them to spawn somewhere else.

2 comments

0

Make sure that this is in a server script, not a localscript.

0

Yep, it's in a server script

1 answer

It is because the humanoidrootpart has wrong CFrame. I am not ENTIRELY sure of that...but I think that is the reason.

3 comments

0

With "wrong" I meant resetted (because when you die CFrame values are changed)

0

uhh, yes CFrame values are changed when you die, but he has already connected the characteradded event, means that it will reposition itself when respawned.

0

this wouldn't exactly explain why it works in studio but not in game though

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