Set JumpPower onTouch

I tried making a script where when you touch you cant jump, but it doesnt work.

function ontouch(part)
    local h = part.Parent:FindFirstChild("Humanoid")
    if h~= nil then
    h.JumpPower = 50

Oh wait. I set the value to 50. Oops.

@PirateDevz Now while this is not wrong I recommend that for h you do a if h:IsA(“Humanoid”) then function.

They are looking for the humanoid, so you would not actually use :IsA since there are multiple children, if you wanted to use :IsA you would have to loop through the children and check every child.

1 Like

Also, you’re using a deprecated “:connect()”, you should use :Connect() since it’s more efficient and up-to-date.

There’s no difference. The functionality of lowercase connect is the same as PascalCase Connect, the former being an alias. It’s not that it’s more efficient; its that its deprecated and shouldn’t be used due to the removal potential. It is being kept because a greater majority of items still use LC connect.

Visually it’d look something like this in code:

local function connect()

RbxInstance.connect = connect
RbxInstance.Connect = connect
1 Like

:FindFirstChildWhichIsA("Humanoid") seems like the simplest solution.