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

Why won't a GUI show up on any player's screen through this function?

Asked by 6 years ago

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

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

ServerScripts 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.

0
Ah, I see. It's part of a big script with quite a few edits to the Workspace so I'll just create a seperate local script. harrybilly2 5 — 6y
0
Looks good but Note: The remoteEvents/Functions that you are firing are supposed to make changes to the Workspace and not player-based things. mudathir2007 157 — 6y
Ad

Answer this question