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

Why won't I respawn in the correct place?

I have a intremission and round system and I'm trying to make it so when it is intermission, the player respawns in the spawn point called lobby, but if you are in the game, then you respawn in the spawn point Main. But I keep on spawning in lobby for some reason. I have my script in a loop that keeps on checking if my string value called status is Intermission or not.

game.Players.PlayerAdded:Connect(function(player)

local admin = game.ReplicatedStorage.Status.Value


while true do
	if admin == "Intermission" then

		player.RespawnLocation = game.Workspace.Lobby

	else

		player.RespawnLocation = game.Workspace.Main
		end
		wait(0.5)
end


end)

Please help!!!

2 answers

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(player)

local admin = game.ReplicatedStorage.Status


while true do
    if admin.Value == "Intermission" then

        player.RespawnLocation = game.Workspace.Lobby

    else

        player.RespawnLocation = game.Workspace.Main
        end
        wait(0.5)
end


end)

9 comments

0

Isn't that the same thing???

0

i dont see the difference

0

admin.Value instead of admin

0

if admin.Value == "Intermission" then

0

yeah, but I had already done admin = game.ReplicatedStorage.Status.Value

0

So there isn't a difference in my mind. Did you test it?

0

you left ;-;

0

Your answer is great, but you did not explain what went wrong. I will cover that in my own answer.

0

But this script, broke my other script. The other script also uses the Status string value. How do i fix that

Hello!

According to your script, the admin stringvalue you got the value from, is obtained at the beginning of the script, therefore not changing, ever.

A fix to this, is to instead replace it with:

local admin = game.ReplicatedStorage.Status

and replace the first line in the while true do loop, with:

if admin.Value == "Intermission" then

which is exactly what scripterhelper5354 here fixed. However, he did not explain what went wrong.

Anyways, if you have any questions, write them below!

I hope this helps!

1 comment

0

Thank you for clarifying!

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