UPDATE: It works (LocalScript) now, which funnily. you can find in jav's answer, however, after the first time I change my class to an accepted Class (i.e. zombie, nighthunter, etc.), it displays a GUI, which respawns when you click a button. When I click it, it puts the GUI back. I've tried to work around this with the 'x' variable, but it still doesn't seem to work.
Hello.
I've been writing a script, where, if a character respawns as certain 'classes' (a StringValue), the script will parent a Gui to them when they respawn.
I've shuffled between using Server-side scripts and LocalScripts, but LocalScripts don't seem to do it, correct me if I'm wrong; and the Server-side scripts is what I had a question about.
Does a CharacterAdded function run separately for each player? Meaning if I declared a variable 'x' (somewhat of a debounce variable), would that 'x' be tagged to that one player respawning, or would the 'x' be the same across all respawns?
Here's the code:
game.Players.PlayerAdded:connect(function(Player)
x = "Stop"
Player.CharacterAdded:connect(function(Character)
wait()
if x == "Go" then
if Player.Class.Value == "Zombie" or Player.Class.Value == "Nighthunter" or Player.Class.Value == "Ogre" or Player.Class.Value == "Thing" or Player.Class.Value == "Imp" or Player.Class.Value == "Golem" or Player.Class.Value == "Savage" then
wait()
_G.StopPlr(Player)
if Player.PlayerGui:FindFirstChild("MonsterSelect") == nil then
local ms = game.ServerStorage.MonsterSelect:clone()
ms.Parent = Player.PlayerGui
x = "Stop"
else print("Defaulted to Zombie Class for ".. Player.Name)
end
else print("ERRRRRR")
end
--controls choose monster GUI
else x = "Go"
end
end)
end)
Notice how I continually reference 'x' in the script? If someone respawns and x is 'Go', and then another person respawns, will that same x change, or will it be an entirely different x altogether? Sorry if that's a bit too confusing.
Thanks for reading; all replies are appreciated!

4 comments
I've tried that exact same thing, actually. It didn't do anything, and as of yet, I haven't found a noticeable issue.
If there's no errors that probably means that the problem is elsewhere. I'm guessing it has something to do with your class system or whatever that is. You can try putting more prints in the script to see what is happening.
I was able to get it to work, but with a drawback. Read the edit in my question.
I just don't have enough information of all that is going on to be able to pinpoint the problem.