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.
01 | game.Players.PlayerAdded:Connect( function (player) |
02 |
03 | local admin = game.ReplicatedStorage.Status.Value |
04 |
05 |
06 | while true do |
07 | if admin = = "Intermission" then |
08 |
09 | player.RespawnLocation = game.Workspace.Lobby |
10 |
11 | else |
12 |
13 | player.RespawnLocation = game.Workspace.Main |
14 | end |
15 | wait( 0.5 ) |
16 | end |
17 |
18 |
19 | end ) |
Please help!!!
01 | game.Players.PlayerAdded:Connect( function (player) |
02 |
03 | local admin = game.ReplicatedStorage.Status |
04 |
05 |
06 | while true do |
07 | if admin.Value = = "Intermission" then |
08 |
09 | player.RespawnLocation = game.Workspace.Lobby |
10 |
11 | else |
12 |
13 | player.RespawnLocation = game.Workspace.Main |
14 | end |
15 | wait( 0.5 ) |
16 | end |
17 |
18 |
19 | end ) |
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:
1 | local admin = game.ReplicatedStorage.Status |
and replace the first line in the while true do
loop, with:
1 | 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!