Hello Roblox Developers,
–Introduction–
I have this glove that when you press E, it shoots out a ball that kills you. After the ball shoots, you have to wait 60 seconds for it to work again. There is a gui called CountdownGui that tells how much time is left.
–Problem–
I’m using a remote event to make the ball appear and shoot. When the player dies, and the remote event is still firing, the CountdownGui glitches, and it just breaks the glove. I tried using removeevent:Disconnect() but it doesn’t work.
How would I be able to stop the remove event when the player dies?
Remote Script:
game.ReplicatedStorage.GodAbility.OnServerEvent:Connect(function(plr, player)
player.Character.God.PunchAnimationScript.Disabled = true
player.PlayerGui.AbilityGUI.Enabled = true
local GAC = game.ServerStorage.GodAbility:Clone()
GAC.Parent = workspace:FindFirstChild(player.Name).God
player.Character.God.SpawnPower.LoopPosition.Disabled = false
player.Character.Humanoid.WalkSpeed = 0
local AnimationTrack = player.Character.Humanoid:LoadAnimation(player.Character.God.PowerAnimation)
AnimationTrack:Play()
wait(4)
GAC.CFrame = player.Character.HumanoidRootPart.CFrame
player.Character.God.SpawnPower.LoopPosition.Disabled = true
GAC.Move.Disabled = false
player.Character.Humanoid.WalkSpeed = 16
GAC.Kill.Disabled = false
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "10"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "9"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "8"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "7"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "6"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "5"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "4"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "3"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "2"
wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = "1"
wait(1)
GAC.Move.Disabled = true
GAC:Destroy()
game.ReplicatedStorage.CountdownGodAbility:Fire(player)
player.Character.God.PunchAnimationScript.Disabled = false
end)
game.ReplicatedStorage.CountdownGodAbility.Event:Connect(function(player)
local countdown = 50
repeat wait(1)
player.PlayerGui.AbilityGUI.AbilityMain.AbilityCount.Text = ""..countdown..""
print(countdown)
countdown -= 1
until
countdown <= -1
player.PlayerGui.AbilityGUI.Enabled = false
player.Character.Sweeper.PunchAnimationScriptAbility.Disable.Disabled = true
end)
LocalScript:
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then -- change the E to any key!
game.ReplicatedStorage.GodAbility:FireServer(player)
script.Disabled = true
wait(61)
player.PlayerGui.PressEGod.Disabled = false
end
end
end)
Video of problem: