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

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

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

✓ Accepted answer

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)

2 comments

0

Thanks dude.

0

Bad way of getting the character. Also why all those unnecessary checks.

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