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

Why is my NPC respawn script not working? I wqant my NPC's to stop spawing once my gui says

Asked by 5 years ago

local NPC = game.ReplicatedStorage.Zombie local spawner = script.Parent GameTime = game.StarterGui.Timer.Frame.TextLabel

if GameTime.Text == "Game" then repeat local Clone = NPC:Clone() Clone.Torso.CFrame = spawner.CFrame Clone.Parent = workspace wait(2) until GameTime.Text == "Intermission" end

1 answer

Log in to vote
0
Answered by 5 years ago
GameTime = game.StarterGui.Timer.Frame.TextLabel

The reason your code isn't working is due to that line up there. "StarterGui" will remain exactly the same like in Studio. You are looking for something known as "PlayerGui", which is essentially a place where everything is copied from StarterGui into the player, which is what they see when they play the game.

DO NOTE HOWEVER: With FilteringEnabled being the standard for games (rightfully so), PlayerGui will not be accessible by the server. This is why it's strongly recommended to, for example, make a StringValue in ServerStorage deciding whether it is Intermission or whether the game is starting, rather than using the player's GUI (which is also a very major security flaw)

Ad

Answer this question