Can someone please fix this script. It doesn't seem to work. This script is placed in the part. The click detector is inside the part along with the script.
01 | button = script.Parent |
02 |
03 | function onClicked (part) |
04 | local player = game.Players:GetPlayerFromCharacter(part.Parent) |
05 | if player ~ = nil then |
06 | local GUI = game.Lighting.ScreenGui |
07 | GUI:Clone().Parent = player.PlayerGui |
08 | end |
09 | end |
10 | end |
11 |
12 | button.Touched:connect(onTouch) |
I suggest keeping the Gui in StarterGui and setting it to invisible. Then, put a script in the brick that has:
function clicked() game.StarterGui.YourGuiNameHere.Visible = true -- Replace with your screengui's name end
script.parent.ClickDetector.Clicked:connect(clicked)
If it doesn't work ill try it out myself.
Fixed it!
1 | function Clicked(hay) |
2 | a = game.Lighting.ScreenGui:Clone() |
3 | a.Parent = hay.PlayerGui |
4 | end |
5 | script.Parent.ClickDetector.MouseClick:connect(Clicked) |