So, I'm trying to make a simple Roblox game similar to Epic Minigames in which a random minigame is picked and players must complete it. It is very incomplete so far and I am having problems with displaying the GUI to players. After calling the chooseGame() function the GUI should show with the game chosen. However, it doesn't, no matter what.
chooseGame() function snippet from a server-side script in ServerScriptService:
function chooseGame() --TODO: math.rand() + if statements for each minigame gameChosen = "BombSurvival" for i, player in pairs(game.Players:GetChildren()) do game.ServerStorage.BombSurvival:Clone().Parent = player.PlayerGui.ScreenGui end end
ServerScript
s cannot access PlayerGui
. Why?
Because StarterGui
is the only "Gui Storage" that they can access and PlayerGui is seperate to all clients so ServerScripts get confused about that.. But that doesn't mean you should switch PlayerGui in your scripts into StarterGui because that won't work...
However, if this is a separate script and not part of a big script then you should turn the script into a local script.. That way it will work.
Also LocalScripts
cannot access the Workspace
so be aware of that.
If it's just part of a big script then you have to turn the entire script into a local script and add remote events and if they react to the Workspace then you should fire them.
If this helps, feel free to accept the answer.