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

Why doesn't my local script open a GUI?

Hey. I'm trying to open up a GUI in PlayerGui from a part. I have the ClickDetector in the part but for some reason the localscript doesn't want to open up the GUI. No errors are shown. Here's the code:

local casegui = game.Players.LocalPlayer.PlayerGui.ScreenGui.ScrollingFrame

script.Parent.ClickDetector.MouseClick:connect(function()
	casegui.Visible = true
end)

1 answer

✓ Accepted answer

###LocalScripts cannot run in Workspace. They can only run in PlayerGui, Backpack, PlayerScripts, Character, and ReplicatedFirst. You'll need a RemoteEvent to make the Gui show.

-- Server script under your part
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShowGui = ReplicatedStorage:WaitForChild("ShowGui")

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    ShowGui:FireClient(player)
end)

###Local code:

--LocalScript, preferably in StarterGui/PlayerGui
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShowGui = ReplicatedStorage:WaitForChild("ShowGui")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local casegui = PlayerGui.ScreenGui.ScrollingFrame

ShowGui.OnClientEvent:Connect(function()
    casegui.Visible = true 
end)

1 comment

0

Thanks! It worked :D

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