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

Simple Script Error Confusion?

Asked by 9 years ago

The script works, it's located in game.Workspace.BasePlate

I keep getting this error message and I don't understand on how to fix it.

Here's the error message: 15:21:29.185 - Humanoid is not a valid member of Tool 15:21:29.186 - Script 'Workspace.BasePlate.Jump/Run Script', Line 5

Thanks for the help.


function onTouch(Player) local human = Player.Parent:FindFirstChild("Humanoid") if human ~= false then Player.Parent.Humanoid.WalkSpeed = 32 Player.Parent.Humanoid.JumpPower = 100 end end script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by
yoshi8080 445 Moderation Voter
9 years ago

Here's the error, you used player, which isn't the best method with a function for my opinion.

I used a part's parent OnTouched to get the player's humanoid. Also, use print(Player) to test what would it show as to help with 'hierarchical parent' if you want to add parents to get the player

function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.WalkSpeed = 32
h.JumpPower = 100
end
end
script.Parent.Touched:connect(onTouched)
Ad

Answer this question