Concept: I want to make modules that contain functions for abilities for each one of my characters that activate whenever I press their buttons. However in the following code the output says my module function was executed when it really wasnt. I can provide more details if asked!
This is the script where the module function is ran, I included some comments to describe what’s going on and the result of some debug prints
--Abilities In Game
--this isnt the full script but i can provide more details if asked
local function syncabilities(infomodule, abilitymodule)
for _, connection in pairs(abilityconnections) do
connection:Disconnect()
end
local ability1info = infomodule.Abilities["Ability1"]
local ability2info = infomodule.Abilities["Ability2"]
Ability1TextLabel.Text = ability1info.Name
Ability2TextLabel.Text = ability2info.Name
local cooldown1 = ability1info.Cooldown
local cooldown2 = ability2info.Cooldown
Ability1Button.Image = ability1info.Image
Ability2Button.Image = ability2info.Image
abilityconnections.ability1 = Ability1Button.Activated:Connect(function()
--this is where the problem is yo
print("Ability1 Started")
local success, error = pcall(function()
abilitymodule.Ability1(player.Character)
print("Ability1 Ended")
end)
if not success then
print("Error in ability1: " .. error)
end
--it prints ability 1 started and ability 1 ended without error but the function doesnt run
Ability1CooldownLabel.Visible = true
Ability1Button.Active = false
for count = cooldown1, 0, -1 do
Ability1CooldownLabel.Text = count
task.wait(1)
end
Ability1CooldownLabel.Visible = false
Ability1Button.Active = true
end)
abilityconnections.ability2 = Ability2Button.Activated:Connect(function()
--ignore this my main focus is ability 1 lol
Ability2CooldownLabel.Visible = true
Ability2Button.Active = false
abilitymodule.Ability2(player.Character)
for count = cooldown2, 0, -1 do
Ability2CooldownLabel.Text = count
task.wait(1)
end
Ability2CooldownLabel.Visible = false
Ability2Button.Active = true
end)
end
--when the game starts, they are given a different in game character
GameStartEvent.OnClientEvent:Connect(function()
local equipped = CharacterEquipped.Value
local character = CharactersFolder:FindFirstChild(equipped)
local charactermodel = player.Character
if not character then return end
local infomodule = require(character:FindFirstChild("InfoPanel"))
local abilitymodule = require(AbilityModules:FindFirstChild(equipped))
if not infomodule or not abilitymodule then return end
syncabilities(infomodule, abilitymodule)
--just some debug
print(abilitymodule.Ability1)
--this ended up printing a functionx0 something
print(abilitymodule)
--this just printed a table of the module with ability1, ability2, and it said it ran on the client which is true
print(AbilityModules:FindFirstChild(equipped).Name)
--this just printed the module name
AbilitiesUI.Enabled = true
end)
here’s the module itself, again some comments so you know whats going on here
local Zorble = {}
--zorble's the character name hes like an alien i guess
function Zorble.Ability1(character)
wait(2)
--even though there's a wait here the "Ability1 Ended" print shows up instantly so this first line doesnt even run
print("Abilityfunctionentered")
--this didnt print either, the rest of the function didnt do anything either
-- these are all just different parts of the ingame character i passed in
local hrp = character:FindFirstChild("HumanoidRootPart")
local AnimSaves = character:FindFirstChild("AnimSaves")
local humanoid = character:FindFirstChild("Humanoid")
local Animator = humanoid:FindFirstChild("Animator")
local Raygun = character:FindFirstChild("Raygun")
print("all is good")
local RaygunFireTrack = Animator:LoadAnimation(AnimSaves.RaygunFire)
RaygunFireTrack:Play()
RaygunFireTrack:GetMarkerReachedSignal("GunAppear"):Wait()
Raygun.Transparency = 0
RaygunFireTrack:GetMarkerReachedSignal("Fire"):Wait()
print("kapow!")
RaygunFireTrack.Ended:Wait()
Raygun.Transparency = 1
end
--ignore ability2
function Zorble.Ability2(character)
print("nothing here yet")
end
return Zorble
extra details:
this is running on the client,
the module is located in a folder in ReplicatedStorage,
the rest of the other script goes normally without executing the module function,
i removed sanity checks in the module function and it still doesnt work
thanks for reading!!



