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

How do I get a GUI to clone into the PlayerGui using a ClickDetector?

Asked by 5 years ago
Edited 5 years ago

This is the current script I have and it is not working, I have it in a local script in a button.

workspace.Button.ClickDetector.Clicked:connect(function(plyr)
    if plyr == game.Players.LocalPlayer then
        workspace.Button.FlashGUI:Clone()["Parent"] = game.Players.LocalPlayer.PlayerGui
    end
end

Any help is always appreciated.

0
You can't say ["Parent"], and can't use a LocalScript. Use a Server, .Parent, and get the PlayerGui like so: plyr.PlayerGui Ziffixture 6913 — 5y
0
I would suggest using a server script, just like Feahren pointed out, add it to player.PlayerGui. halfvedantpandya1234 6 — 5y
0
So what I have is https://gyazo.com/a76a02c009685de31fcaa263f6d46838 and it still doesnt not work. ReeseTP 7 — 5y
0
You can't use the LocalPlayer on Server because the Server doesn't have a LocalPlayer, quite logically. use game.Players[plyr] then Ziffixture 6913 — 5y
View all comments (2 more)
0
So im still trying and for some reason I can't get it to work. I've tried doing it several different ways, including the way you told me to do it and it still wont work. ReeseTP 7 — 5y
0
You do not need to use ["Parent"] after the :Clone() function, as you can simply do :Clone().Parent GamingZacharyC 152 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

I would suggest using a server script. Inside Clicked function you could do:

workspace.FlashGUI:Clone(plyr.PlayerGui)
0
No. This is entirely wrong. DeceptiveCaster 3761 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

UPDATE:

I got it to work in a simple way using a LOCAL script. Heres the code:

local plyr = game.Players.LocalPlayer



function onClick()
    script.Parent.FlashGUI:Clone().Parent = plyr.PlayerGui
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)
0
I have a suggestion, its better to use game:GetService("Players").LocalPlayer than game.Players.LocalPlayer. 8_zn 21 — 5y
0
I have got it to actually work this time. Heres the full script: https://pastebin.com/BaZRQUHi ReeseTP 7 — 5y

Answer this question