JumpPower change to the player when seated

Hello Developers!

I have been attempting to make a system, where if a player is seated and a specific BoolValue is true, then the player’s JumpPower is set to 50, but if the value is false, then that player’s JumpPower will be set to 0.

I’ve got the if statements all working, but my only struggle is getting the JumpPower part to work.

This is a script that is placed inside of the seat:

local seat = script.Parent

local LeftDoor = game.Workspace.EurekaTrainSystemV2e.Train["Type 310"].DoorL
local RightDoor = game.Workspace.EurekaTrainSystemV2e.Train["Type 310"].DoorR

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local Char = seat.Occupant.Parent
	local hum = Char.Character:WaitForChild("Humanoid")
	if LeftDoor.Value == true then
		hum.JumpPower = 50
		print("Left door open, can stand")
	elseif RightDoor.Value == true then
		hum.JumpPower = 50
		print("Right door open, can stand")
	else
		hum.JumpPower = 0
		print("No doors open, cannot stand")
	end
end)

I receive these errors when I sit in the seat:

All responses will be greatly appreciated, thanks!

1 Like

First off, you tried getting the character from the character. This is the cause of the second error.
The first error is because when the player leaves the seat there is no occupant, try this script:

local seat = script.Parent

local LeftDoor = game.Workspace.EurekaTrainSystemV2e.Train["Type 310"].DoorL
local RightDoor = game.Workspace.EurekaTrainSystemV2e.Train["Type 310"].DoorR

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    if not seat.Occupant then return end
	local Char = seat.Occupant.Parent
	local hum = Char:WaitForChild("Humanoid")
	if LeftDoor.Value == true then
		hum.JumpPower = 50
		print("Left door open, can stand")
	elseif RightDoor.Value == true then
		hum.JumpPower = 50
		print("Right door open, can stand")
	else
		hum.JumpPower = 0
		print("No doors open, cannot stand")
	end
end)
2 Likes

Hi! There is no more error, however the JumpPower part of the script still appears to not be working. Is there any issue with hum.JumpPower = 50?

Nevermind! My mistake. The world was set to be JumpHeight and not JumpPower. Thank you very much for the help.