Help with jump Script (3)

Hello there, I have been trying to make a script where when the player jumps they will do an ollie on their skateboard. However, nothing happens. I figured out that the if statement doesn’t go off when the player jumps. I have tried many different solutions but none have worked. It would be great if I could have some help because I don’t know what I’m doing. Thank you for your help!

Script

local humanoid = script.Parent.Parent.Parent.Humanoid

humanoid.StateChanged:Connect(function(new)
	print("1")
	if new == Enum.HumanoidStateType.Jumping then -- detected jumping 
		print("2")

		JumpEnabled = false
		SetAnimation("Stop", {Animation = GetAnimation("BoardKick")})
		SetAnimation("Stop", {Animation = GetAnimation("LeftTurn"), FadeTime = 0.5})
		SetAnimation("Stop", {Animation = GetAnimation("RightTurn"), FadeTime = 0.5})
		SetAnimation("Play", {Animation = GetAnimation("Ollie"), FadeTime = 0, Weight = 1, Speed = 4})
		Board.StickyWheels = false
		Board:ApplySpecificImpulse(Vector3.new(0, 45, 0))
		OllieThrust.force = Vector3.new(0, 45, 0)
		DidAction("Jump")
		delay(0.1, function()
			if OllieThrust then
				OllieThrust.force = Vector3.new(0, 0, 0)
			end
		end)
	end
end)
local humanoid = script.Parent.Parent.Parent.Humanoid

humanoid.StateChanged:Connect(function(new)
	print("1")
	if humanoid:GetState() == Enum.HumanoidStateType.Jumping then
		print("2")
		JumpEnabled = false
		SetAnimation("Stop", {Animation = GetAnimation("BoardKick")})
		SetAnimation("Stop", {Animation = GetAnimation("LeftTurn"), FadeTime = 0.5})
		SetAnimation("Stop", {Animation = GetAnimation("RightTurn"), FadeTime = 0.5})
		SetAnimation("Play", {Animation = GetAnimation("Ollie"), FadeTime = 0, Weight = 1, Speed = 4})
		Board.StickyWheels = false
		Board:ApplySpecificImpulse(Vector3.new(0, 45, 0))
		OllieThrust.force = Vector3.new(0, 45, 0)
		DidAction("Jump")
		delay(0.1, function()
			if OllieThrust then
				OllieThrust.force = Vector3.new(0, 0, 0)
			end
		end)
	end
end)
1 Like

Same problem the “if” statement doesn’t work. Thanks for the help though

Weird, have you tried printing the state directly after the event is fired? Might be an internal issue.

sorry I don’t know what you mean by that?

Have 2 questions,

Is it only printing 1 or is it printing 1 and 2 when jumping?

When print(new) while jumping, what do you get in the output?

Add print(humanoid:GetState()) directly after the event is fired. So before print("1") in the script. You could also add print("new") as well.

2 Likes

1- I put the “print” in to see where the problem was.

2 - Nothing All I get Is the first print but not the second

Ok do what @Limited_Unique suggested and tell us what you get

Screenshot 2021-10-23 181935
here’s what I got in the output

Hey so I think I know the problem, so is this a server script or a local script cause local scripts are very buggy at points or it could be that the code runs after the player jumped. Instead, try using User InputService so whenever the player presses spacebar an event fires and does the ollie.

Yeah Its in a local script but I have already tried user-input service and it didn’t work here’s the code i used

local function Jump(Button, jump)


	if JumpEnabled and math.abs(Board.Velocity.Y) < 5 then
		JumpEnabled = false
		SetAnimation("Stop", {Animation = GetAnimation("BoardKick")})
		SetAnimation("Stop", {Animation = GetAnimation("LeftTurn"), FadeTime = 0.5})
		SetAnimation("Stop", {Animation = GetAnimation("RightTurn"), FadeTime = 0.5})
		SetAnimation("Play", {Animation = GetAnimation("Ollie"), FadeTime = 0, Weight = 1, Speed = 4})
		Board.StickyWheels = false
		Board:ApplySpecificImpulse(Vector3.new(0, 45, 0))
		OllieThrust.force = Vector3.new(0, 45, 0)
		DidAction("Jump")
		delay(0.1, function()
			if OllieThrust then
				OllieThrust.force = Vector3.new(0, 0, 0)
			end
		end)
	else
		Board.StickyWheels = true
	end
end

UserInputService.JumpRequest:Connect(Jump)

Mabey try this?

local humanoid = script.Parent.Parent.Parent.Humanoid

humanoid.Changed:Connect(function(new)
	print("1")
	if new == "Jumping" then -- detected jumping 
		print("2")

		JumpEnabled = false
		SetAnimation("Stop", {Animation = GetAnimation("BoardKick")})
		SetAnimation("Stop", {Animation = GetAnimation("LeftTurn"), FadeTime = 0.5})
		SetAnimation("Stop", {Animation = GetAnimation("RightTurn"), FadeTime = 0.5})
		SetAnimation("Play", {Animation = GetAnimation("Ollie"), FadeTime = 0, Weight = 1, Speed = 4})
		Board.StickyWheels = false
		Board:ApplySpecificImpulse(Vector3.new(0, 45, 0))
		OllieThrust.force = Vector3.new(0, 45, 0)
		DidAction("Jump")
		delay(0.1, function()
			if OllieThrust then
				OllieThrust.force = Vector3.new(0, 0, 0)
			end
		end)
	end
end)

can you try that and add a print(“works”) after the line if JumpEnabled and show me what the output is?

Skateboard puts Humanoid in PlatformStand state. You can’t move or jump while in PlatformStand. You are stuck to the board.

But the Skateboard script definitely does something if you press the Space Bar. Go to that bit, and mod it…

1 Like

Sorry, I’m late to reply, Thanks for helping me out! Sadly the script doesn’t work.

Yes, the original skateboard script works but only for computers, not for tablets. I have tried to get it to work for some time and it doesn’t work.

Here is the original script
function ButtonChanged(Button, jump)
	local ButtonState = Controller:GetButton(Button)
	if not ButtonState and not jump then
		return
	end
	if Button == Enum.Button.Dismount then
		Board.ControllingHumanoid.Jump = ButtonState
	elseif Button == Enum.Button.Jump or jump then
		if JumpEnabled --[[and math.abs(Board.Velocity.Y) < 5]] then
			JumpEnabled = false

			SetAnimation("Stop", {Animation = GetAnimation("BoardKick")})
			SetAnimation("Stop", {Animation = GetAnimation("LeftTurn"), FadeTime = 0.5})
			SetAnimation("Stop", {Animation = GetAnimation("RightTurn"), FadeTime = 0.5})
			SetAnimation("Play", {Animation = GetAnimation("Ollie"), FadeTime = 0, Weight = 1, Speed = 4})
			Board.StickyWheels = false
			Board:ApplySpecificImpulse(Vector3.new(0, 45, 0))
			OllieThrust.force = Vector3.new(0, 45, 0)
			DidAction("Jump")
			delay(0.1, function()
				if OllieThrust then
					OllieThrust.force = Vector3.new(0, 0, 0)
				end
			end)
		else
			Board.StickyWheels = true
		end
	end
end
1st try
local function Jump(Button, jump)


	if JumpEnabled and math.abs(Board.Velocity.Y) < 5 then
		JumpEnabled = false
		SetAnimation("Stop", {Animation = GetAnimation("BoardKick")})
		SetAnimation("Stop", {Animation = GetAnimation("LeftTurn"), FadeTime = 0.5})
		SetAnimation("Stop", {Animation = GetAnimation("RightTurn"), FadeTime = 0.5})
		SetAnimation("Play", {Animation = GetAnimation("Ollie"), FadeTime = 0, Weight = 1, Speed = 4})
		Board.StickyWheels = false
		Board:ApplySpecificImpulse(Vector3.new(0, 45, 0))
		OllieThrust.force = Vector3.new(0, 45, 0)
		DidAction("Jump")
		delay(0.1, function()
			if OllieThrust then
				OllieThrust.force = Vector3.new(0, 0, 0)
			end
		end)
	else
		Board.StickyWheels = true
	end
end

UserInputService.JumpRequest:Connect(Jump)
2nd try
local humanoid = script.Parent.Humanoid
local userinputservice = game:GetService("UserInputService")

humanoid.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Jumping then -- detected jumping 
		--script would go here
	end
end)

Nothing happened when when the player jumped