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

I need a Clickdetector script to pop out a localgui ?

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

✓ Accepted answer

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

6 comments

0

Props to this one

0

now usually this wouldnt work cuz serverscripts cant see playergui.. but apparently now it can? am confused

0

Server can add to the PlayerGui which is all I'm doing. Nothing is new here.

0

@Imperialy, the server cannot access existing members of the PlayerGui. It can add to it, though, and of course access those members.

0

Thanks so much! didnt know someone would help me that fast , thanks anyway

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.

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