So I’m trying to change the jump height of a player after they touch a part in the workspace.
Right now, the script isn’t doing anything in changing the jump height of a player.
I’ve tried looking through a few posts, and none of them work. I tried using a script that did something else that changed the walkspeed of a player, but changing that didn’t work so I’m struggling to make it work.
local player = game:GetService("StarterPlayer")
local part = script.Parent
local function onTouch(jump)
local humanoid = jump.Parent:FindFirstChild('Humanoid')
if humanoid then
player.CharacterJumpHeight = 10
end
end
part.Touched:Connect(onTouch)
I think it should be player.Character.Humanoid.JumpHeight = 10
Also you can’t define the player as that.
Try this
local part = script.Parent
local function onTouch(hit)
if hit and hit.Parent then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.Character.Humanoid.JumpHeight = 10
end
end
end
part.Touched:Connect(onTouch)
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.JumpPower = 100 -- Set the number to the desired jump power
end
end)
In that case, the solution I provided should still work as long as you replace JumpPower with JumpHeight.
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.JumpHeight = 100 -- Set the number to the desired jump height
end
end)