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

GUI appears in build mode but not play mode?

Asked by 5 years ago

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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
5 years ago

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

0
Where do I put the GUI in the PlayerGui? squidiskool 208 — 5y
Ad
Log in to vote
0
Answered by
KingDomas 153
5 years ago

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.

Answer this question