Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

2 comments

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.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.