Why is this CAS isn't working

So i was experiencing rojo and VSCode a few months now and well… Naturally i tried to make a game with it.

And the problem here is that this client script doesn’t work:

local plrs = game:GetService("Players")
local reps = game:GetService("ReplicatedStorage")
local cas = game:GetService("ContextActionService")
local runs = game:GetService("RunService")
local plr = plrs.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local modules = reps.modules
local main = require(modules.main).new()

local function onUpdate(dt)
    main:update(dt)
end

local function onFire(actionName, inputState)
    if actionName == "pewpew" and inputState == Enum.UserInputState.Begin then
        main:fire(true)
    elseif actionName == "pewpew" and inputState == Enum.UserInputState.End then
        main:fire(false)
    end
end

local function onReload(actionName, inputState)
    if actionName == "reload" and inputState == Enum.UserInputState.Begin then
        main:reload(true)
    end
end

local function onEquip(tool)
    main:equip(tool)
    print("equipping")
    cas:BindAction("pewpew", onFire, true, Enum.UserInputType.MouseButton1)
    cas:BindAction("reload", onReload, true, Enum.KeyCode.R)
end

local function onUnequip()
    main:unequip()
    print("unequipping")
    cas:UnbindAction("pewpew")
    cas:UnbindAction("reload")
end

char.ChildAdded:Connect(function(child)
    if child:IsA("Tool") then
        print("tool equipped")
        onEquip(child)
    end
end)

char.ChildRemoved:Connect(function(child)
    if child:IsA("Tool") then
        print("tool unequipped")
        onUnequip()
    end
end)

runs.RenderStepped:Connect(onUpdate)

(If i didn’t mentioned earlier this is in starterScripts, specifically StarterPlayerScripts)

I have trouble figuring out what caused this and this only applies to this script specifically, the others are unaffected.
Please help :cry:

1 Like

can I get more info on what’s not working exactly? does it just error or smh else? I took a quick glance at the code seems fine though

Yeah it works fine and there’s not even an error but the tool isn’t recognized being equipped and the code just apparently doesn’t work

edit 1: Weird somehow it does not have any activity? Impossible.

1 Like