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

Why is this script preventing me from jumping?

I was testing out stuff on my place, then I noticed that I couldn't jump. After disabling some scripts to find what was causing it, it was just this one script. Does anyone know how to stop this?

local actionservice = game:GetService("ContextActionService")
local character = game.Players.LocalPlayer.Character

function DoubleJump(actionName, actionInputState, actionInputObject)
	if character.Humanoid:GetState() == Enum.HumanoidStateType.Jumping or character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
		print("poof")
	end
end

actionservice:BindAction("DoubleJump", DoubleJump, false, " ")

(the script that is causing it)

1 answer

The space bar already has an action bound to it.. making you jump :D

You're overwriting that with code that prints if you're falling or jumping..

I would suggest using the InputBegan event of UserInputService.

local inputservice = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local jumping = Enum.HumanoidStateType.Jumping
local falling = Enum.HumanoidStateType.FreeFall

function DoubleJump(i,p)
	if not p then
		if i.KeyCode == Enum.KeyCode.Space then
			local state = hum:GetState()
			if state == jumping or state == falling then
				print("poof")
			end
		end
	end
end

inputservice.InputBegan:Connect(DoubleJump)

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