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

GUI appears in build mode but not play mode?

Hello, I'm trying to make a script which opens a GUI when you click a part. But for some reason it does not appear. It says Enabled but it doesn't even appear. In build mode when it says Enabled it does appear. What is going on and can anybody tell me what is going on?

game.Workspace.SpawnCarScreenOpen.OnServerEvent:Connect(function()
	game.StarterGui.CarSelectScreen.Enabled = true
end)
local clickdetector = game.Workspace.CarSelector.ClickDetector
clickdetector.MouseClick:Connect(function()
	game.Workspace.SpawnCarScreenOpen:FireServer()
end)

2 answers

✓ Accepted answer

You are in fact enabling a GUI, however it's the one placed in StarterGui. To access a Player's GUI, you'll have to go through their PlayerGui. If you make the script a local script, you can achieve your goal with:

local clickdetector = game.Workspace.CarSelector.ClickDetector
clickdetector.MouseClick:Connect(function()
	game.Players.LocalPlayer:WaitForChild('PlayerGui').CarSelectScreen.Enabled = true
end)

To reference the player in a local script, it is game.Players.LocalPlayer. Note: For this to work, the local script would have to be placed within the player. Could be in StarterPlayer > StarterPlayerScripts

1 comment

0

Where do I put the GUI in the PlayerGui?

Not completely sure about this but here we go: Don't use .Enabled instead use .Visible If I'm correct, Enabled makes it visible/not visible in studio but .Visible makes it on the game. Try it, but since I'm not the best at Rlua, it may not work.

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