For some reason, my cooldown module will clone an instance. This sounds really confusing so ill try to explain it
I press one on my keyboard. The move activates and an instance is cloned from replicated storage. I press 1 again after the cooldown has ended and the instance is cloned twice. I press 1 a third time and the instance is cloned 3 times. So on and so forth
Heres a video example for a better understanding
Heres all the relevant code
–Cooldown
local module = {}
local SS = game:GetService("ServerStorage")
function module.Cooldown(plr,check,name,howlong)
local CDFolder = SS.Cooldowns
if check == true then
if CDFolder:FindFirstChild(plr.Name..name) then
return "On CD"
else
return "Off CD"
end
else
local value = Instance.new("BoolValue")
value.Name = plr.Name..name
value.Parent = CDFolder
game:GetService("Debris"):AddItem(value, howlong)
end
end
return module
–Client
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.One then
local check = event:InvokeServer({1, "Start"})
local HRP = char.HumanoidRootPart
if check == "Proceed" then
--Humanoid Walkspeed
hum.WalkSpeed = 0
hum.JumpHeight = 0
anims.Fireball:Play()
anims.Fireball:GetMarkerReachedSignal("Summon"):Connect(function()
VEvent:FireServer("Yellow Circle",HRP.CFrame)
end)
anims.Fireball:GetMarkerReachedSignal("Fire"):Connect(function()
local check2 = event:InvokeServer({1, "Fireball"})
if check2 == true then
print("Cooldown Successful")
hum.WalkSpeed = 16
hum.JumpHeight = 7.2
end
end)
end
end
–Server
event.OnServerInvoke = function(plr,args)
-------------------------
local module = require(Services.SS.Cooldown)
local char = plr.Character
local HRP = char.HumanoidRootPart
local hum = char.Humanoid
local BP = plr.Backpack
local Active = BP.Active
-------------------------
if args[1] == 1 then
if args[2] == "Start" then
if module.Cooldown(plr,true,"Move 1") == "Off CD" then
if Active.Value == false then
Active.Value= true
module.Cooldown(plr, false, "Move 1", 5)
return "Proceed"
end
end
elseif args[2] == "Fireball" then
print("Fireball Succesful")
task.wait(5)
Active.Value = false
return true
end
end
end
Help would really be appriciated, ive been looking for a solution for awhile and i dont see any bugs or errors. Thank you for your time
EDIT: VEvent is just a visual effects thing. It sends things to the server which send said things to all clients so that part is ignorable