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

Simple Script Error Confusion?

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

✓ Accepted answer

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)

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