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

Why won't I respawn in the correct place?

Asked by
Xyternal 247 Moderation Voter
3 years ago

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.

01game.Players.PlayerAdded:Connect(function(player)
02 
03local admin = game.ReplicatedStorage.Status.Value
04 
05 
06while 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)
16end
17 
18 
19end)

Please help!!!

2 answers

Log in to vote
2
Answered by 3 years ago
01game.Players.PlayerAdded:Connect(function(player)
02 
03local admin = game.ReplicatedStorage.Status
04 
05 
06while 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)
16end
17 
18 
19end)
0
Isn't that the same thing??? Xyternal 247 — 3y
0
i dont see the difference Xyternal 247 — 3y
0
admin.Value instead of admin scripterhelper5354 896 — 3y
0
if admin.Value == "Intermission" then scripterhelper5354 896 — 3y
View all comments (5 more)
0
yeah, but I had already done admin = game.ReplicatedStorage.Status.Value Xyternal 247 — 3y
0
So there isn't a difference in my mind. Did you test it? Xyternal 247 — 3y
0
you left ;-; Xyternal 247 — 3y
0
Your answer is great, but you did not explain what went wrong. I will cover that in my own answer. RAFA1608 543 — 3y
0
But this script, broke my other script. The other script also uses the Status string value. How do i fix that Xyternal 247 — 3y
Ad
Log in to vote
1
Answered by
RAFA1608 543 Moderation Voter
3 years ago
Edited 3 years ago

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:

1local admin = game.ReplicatedStorage.Status

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

1if 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!

0
Thank you for clarifying! Xyternal 247 — 3y

Answer this question