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

How would I connect to a players humanoid when he/she click a button?

Asked by 6 years ago

So when someone for example "CoolMan3" clicks a physical button (not GUI) it will connect to his humanoid, and then from there, I am pretty much free to do what I want with his character.

<--- button

# (._.) <--- "CoolMan3" hits button

Connects to his humanoid. I can change health, walk speed, etc

That's just if you need some more explanation. If you can give me a basic script on how to do it, and explain it would be cool. Thanks!

1 answer

Log in to vote
0
Answered by 6 years ago

I'm assuming that you already have a click detector inside of a part in the workspace, if you don't, you should do that. Now we have to connect the click detector to a function so we can actually, well, click it. That would look like this:

-- This script should be in the button

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    if workspace:FindFirstChild(plr.Name) then
        if workspace[plr.Name]:FindFirstChild("Humanoid") then
            h = workspace[plr.Name].Humanoid
            -- do whatever you want
        end
    end
end)
0
Thanks dude. MarioGenci -5 — 6y
0
Bad way of getting the character. Also why all those unnecessary checks. User#24403 69 — 6y
Ad

Answer this question