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

Why won't my gui become visible after clicking the part?

Asked by 4 years ago
script.Parent.ClickDetector.MouseClick:Connect(function()
    local gui = game.Players.LocalPlayer.PlayerGui.WantLuck -- Name of Gui
    gui.Frame.Visible = true
end)

This seems like it should work to me. I have tried this script in both Local and regular script. Every time I click the part nothing happens. No errors in the output. How would you make a script that opens a gui after being clicked?

1 answer

Log in to vote
0
Answered by 4 years ago

ServerScripts can't look into PlayerGui and LocalScripts doesn't work in Workspace. To solve this you will have to use a RemoteEvent. Start with creating a RemoteEvent in ReplicatedStorage and name it what suits you, then you create a LocalScript in "WantLuck" and a ServerScript in your Part.

ServerScript

local remEvent = game.ReplicatedStorage.RemoteEvent -- change this to the name of your Event
script.Parent.ClickDetector.MouseClick:Connect(function(player)
    remEvent:FireClient(player)
end)

LocalScript

local remEvent = game.ReplicatedStorage.RemoteEvent -- change this to the name of your Event aswell
remEvent.OnClientEvent:Connect(function()
    script.Parent.Frame.Visible = true
end)

I hope this helped and if so I would gladly appreciate if you could accept my answer.

Ad

Answer this question