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

Script that only affects who clicked?

Asked by 9 years ago

I need to make a script for my GUI that only works on the one who clicked? What do I do or use? Do I just need to use a localscript?

2 answers

Log in to vote
0
Answered by 9 years ago

Use local script and here's the ouline of what you need

function onClicked()
 ---Put what you want it to do here
end

script.Parent.MouseButton1Click:connect(onClicked)
0
You don't need it to be a local script. It cannot be a local script if the gui is not in the player BTW. EzraNehemiah_TF2 3552 — 9y
Ad
Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
9 years ago

Well, try this:

function Clicked()
    local player = script.Parent.Parent.Parent.Parent -- The player in the 'Players' service.
    -- If  you put the button inside something, add a .Parent to it.

    -- Put your script here
end

script.Parent.MouseButton1Click:connect(Clicked) -- Put this script in the button

I hope that helped!

Answer this question