How do I access a player's HUMANOID when I click. This question is simply how do I find the player that is clicking the button and access their humanoid?
part = script.Parent
function Activated(click) if game.Workspace.--where is the player located?!?-- then Humanoid.WalkSpeed = 100 else print("False") end end
script.Parent.ClickDetector.MouseClick:Connect(Activated)
When asking/answering questions remember to put the code in a code block.
To put your code in a code block, click the Lua icon that is above the question/answer box. This will generate lines of tildes (~~~~) to paste the code in between the tildes.
By default, the argument passed to your event listener is the player who clicked the button. With that in mind, you can use player.Character.Humanoid
to get the humanoid.
local part = script.Parent -- # always use local variables local function Activated(player) player.Character.Humanoid.WalkSpeed = 100 end part.ClickDetector.MouseClick:Connect(Activated)
The 'click' parameter, as you have it, is the player that clicked. You can access their character just by doing click.Character
then path to the Humanoid:
local part = script.Parent local cd = part.ClickDetector cd.MouseClick:Connect(function(playerWhoClicked) playerWhoClicked.Character.Humanoid.WalkSpeed = 100 end)