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

I need a Clickdetector script to pop out a localgui ?

Asked by
Anto3oo 13
5 years ago

Hey im new to the scripting helpers plus new to roblox studio scripting so i need a little help from you. Well , i need a LocalGui to appear when you click a part , (i have the clickdetector done and i have tested it with print) but its not working for me ( on the second line there is my name because idont know how to get there localplayer

function OnClick()
    playerfind = game.Players:FindFirstChild(script.Parent.Parent.Anto3oo.Name.Value) 
    guiclone = script.Buyframe:clone() 
    guiclone.Parent.Parent.Parent = playerfind.PlayerGui 
end
script.Parent.ClickDetector.MouseClick:connect(OnClick)


The location of the script is

game.Workspace.Blender.script

And the gui is

game.Workspace.Blender.script.BuyFrame

1 answer

Log in to vote
1
Answered by
xPolarium 1388 Moderation Voter
5 years ago
Edited 5 years ago

The MouseClick event from the ClickDetector provides you with the player that clicked. Knowing this you could directly access their PlayerGui to add a new Gui.

function OnClick(playerThatClicked)
    local guiclone = script.Buyframe:Clone() --Use :Clone()
    guiclone.Parent = playerThatClicked.PlayerGui 
end

script.Parent.ClickDetector.MouseClick:Connect(OnClick) --connect is deprecated. Use Connect.

This adds a Gui to the Player using the server. You could also do this using a local script to have more functionality when editing the gui.

If I missed anything or you need anything explained let me know.

MouseClick Event

0
Props to this one Ziffixture 6913 — 5y
0
now usually this wouldnt work cuz serverscripts cant see playergui.. but apparently now it can? am confused Imperialy 149 — 5y
0
Server can add to the PlayerGui which is all I'm doing. Nothing is new here. xPolarium 1388 — 5y
0
@Imperialy, the server cannot access existing members of the PlayerGui. It can add to it, though, and of course access those members. Gey4Jesus69 2705 — 5y
View all comments (2 more)
0
Thanks so much! didnt know someone would help me that fast , thanks anyway Anto3oo 13 — 5y
0
Assuming you have my exact code, it should be a server Script inside the Part you click with a ClickDetector in that Part too. Make sure your "Buyframe" is inside the script so it can clone it. Read the hierarchy path in the script to see what I mean. xPolarium 1388 — 5y
Ad

Answer this question