I am making a script for my game that shows a GUI to each individual player after a certain condition is met. Here is the relevant code that I am having trouble with:
This first block of code comes from a server script which accesses ServerStorage and finds the relevant GUI that I want to display. Its purpose is to enable a local script in StarterPlayerScripts.
local gameStatus = script.Parent.GameStatus
local roleGUI = game.StarterGui.GUIs.RoleGUI
while wait(1) do
while gameStatus.Value == "Starting" do
print("Game started!")
game.StarterPlayer.StarterPlayerScripts.Role.Disabled = false
wait(1)
end
end
...And here is the code from the local script.
print("Working!")
local roleGUI = game.StarterGui.GUIs.RoleGUI:Clone()
roleGUI.Frame.Visible = true
roleGUI.Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
I have tested this before in Play Solo mode (I'm aware that solo mode and start server are two different things; I don't think this is the problem here) with the disabled property off and everything works fine. However, whenever I manually toggle the disabled property on, the code doesn't run and the case doesn't seem to be the same when I attempt to this with start server mode.
Could somebody please help me understand what is causing the problem?

3 comments
ServerScriptService.GameState.Starting:1: attempt to index field 'LocalPlayer' (a nil value) - this was returned by the server script.
Done, I edited my answer, sorry for that error, but I already fixed it. Try again!
ServerScriptService.GameState.Starting:20: 'end' expected (to close 'function' at line 1) near '' - where is end supposed to close the function?