Why isn't this script working?

I’m using a local script and a module script so that I can make a move set for the player. The issue is, nothing is being outputted in the output, and so I’m not sure what I’m supposed to do because there’s no errors.

Local Script

local player = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Input = game:GetService("UserInputService")
local moveModule = require(game:GetService("ReplicatedStorage"):WaitForChild("Player"):WaitForChild("Moveset"))

local char = game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")

local CAS = game:GetService("ContextActionService")
local state = nil

local moves = moveModule.moves

CAS:BindAction("Crouch", moves, false, Enum.KeyCode.LeftControl) -- Crouch
CAS:BindAction("Dive", moves, false, Enum.KeyCode.E) -- Dive
CAS:BindAction("LJ", moves, false, Enum.KeyCode.LeftShift and Enum.KeyCode.Space) -- Long Jump
CAS:BindAction("GP", moves, false, Enum.KeyCode.LeftShift and Enum.KeyCode.Space) -- Ground Pound

Module Script

local module = {}

module.LJCoolDown = false
module.CCooldown = false
module.DCooldown = false
module.GPCooldown = false

local state = ""

function module.moves(action, inputState, inputObject)
	if action == "LJ" then
		if inputState == Enum.UserInputState.Begin and not module.LJCoolDown then
			module.LJCoolDown = true print("Long Jump Activated") 
			
			task.wait(2)
			
			module.LJCoolDown = false
		else return end elseif action == "Crouch" then
		if inputState == Enum.UserInputState.Begin and not module.CCooldown then
			module.CCooldown = true print("Crouch Activated")
			
			task.wait(1)
			
			module.CCooldown = false
		else return end elseif action == "Dive" then
		if inputState == Enum.UserInputState.Begin and not module.DCooldown then
			module.DCooldown = true print("Dive Activated")
			
			task.wait(1)
			
			module.DCooldown = false
		else return end elseif action == "GP" then
		if inputState == Enum.UserInputState.Begin and not module.GPCooldown and state ~= "Freefalling" then
			module.GPCooldown = true print("Ground Pound Activated")
			
			task.wait(1)
		end
	end
end

return module

Did you replace “and” with a comma instead? “And” will make this statement true or the space enum.

and does not include both Enums, it will evaluate to true.

Your code should be:

-- Use a comma
CAS:BindAction("LJ", moves, false, Enum.KeyCode.LeftShift, Enum.KeyCode.Space)
CAS:BindAction("GP", moves, false, Enum.KeyCode.LeftShift, Enum.KeyCode.Space)

were am I using a comma ???

That doesn’t do anything but just binds another keycode to the action.

@HugeCoolboy2007

Then what are you trying to achieve?

I’m trying to make it so that the character has to use two keybinds to activate the long jump

In that case, you should use the comma and have both of them (or use the last keybind needed to activate), and then add a variable to see if the key is down (or use :IsKeyDown)

1 Like