Client (localscript) inside starter player scripts
local Players = game:GetService("Players")
local player = Players.LocalPlayer
player.CharacterAdded:Connect(function()
local CrateClient = require(modules:WaitForChild("CrateClient"))
local fireCrate = events:WaitForChild("FireCrate")
--A shitload of variables
local crateconnect = nil
local function firecrateEvent(var, winner, number)
CrateClient:fireCrate(var, winner, number, crateconnect)
end
crateconnect = fireCrate.OnClientEvent:Connect(firecrateEvent)
end)
The issue I'm having is that every time I try to play the crate game it will double fire so I assumed it was the :Connect function not disconnecting properly after I finish playing it so I added a disconnect() function inside the module script. The function wont run again after its been disconnected how do I disconnect the function and reconnect it again if I decide to play it again (ofcoarse without resetting my character every time as this is also nested inside the characteradded function aswell).
I will post more code if required
** You are now Level 4! **