Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Solved] Moves can only be used once even after waiting for cooldown?

Asked by
iiii676 23
4 years ago
Edited by chess123mate 4 years ago

Here is the first move script.

01local Player = game.Players.LocalPlayer
02 
03local Character = Player.Character or Player.CharacterAdded:Wait()
04 
05local debounce = false
06script.Parent.MouseButton1Click:Connect(function()
07    if Character.HumanoidRootPart.Anchored == false then
08        if debounce == false then
09 
10            debounce = true
11 
12            if Player.leaderstats.Nature.Value == "Fire" then
13                game.ReplicatedStorage.FireWall:FireServer()
14            elseif Player.leaderstats.Nature.Value == "Grass" then
15                game.ReplicatedStorage.GWall2:FireServer()
View all 23 lines...

Even after waiting for the 9 seconds, I cant use the move or any other moves from this script.

Here is the second script

01local Player = game.Players.LocalPlayer
02 
03local Character = Player.Character or Player.CharacterAdded:Wait()
04 
05local debounce = false
06script.Parent.MouseButton1Click:Connect(function()
07        if Character.HumanoidRootPart.Anchored == false then
08            if not debounce then
09 
10                debounce = true
11 
12                    if Player.leaderstats.Nature.Value == "Fire" then
13                        game.ReplicatedStorage.ShootFireBall:FireServer()
14                    elseif Player.leaderstats.Nature.Value == "Grass" then
15                        game.ReplicatedStorage.ShootGrassBall:FireServer()
View all 23 lines...

I dont know why, but its the same thing with this script. After using this move, the cooldown timer never goes back to false.

2 answers

Log in to vote
0
Answered by 4 years ago

i've been having the same problem to, i think its just roblox. After I wait the timer the rest of the code breaks, i have had to make whole timers to fix this such as below. Hopefully ROBLOX fixes this. The timer is just a demonstration of what i've had to do!

01local Timer = {}
02Timer.__index = Timer
03 
04function Timer.new()
05    local self = setmetatable({}, Timer)
06 
07    self._finishedEvent = Instance.new("BindableEvent")
08    self.finished = self._finishedEvent.Event
09 
10    self._running = false
11    self._startTime = nil
12    self._duration = nil
13 
14    return self
15end
View all 59 lines...
Ad
Log in to vote
0
Answered by
iiii676 23
4 years ago

Never Mind, I actually just figured this out on my own.

01local Player = game.Players.LocalPlayer
02 
03local Character = Player.Character or Player.CharacterAdded:Wait()
04 
05local debounce = false
06script.Parent.MouseButton1Click:Connect(function()
07        if Character.HumanoidRootPart.Anchored == false then
08            if not debounce then
09 
10                debounce = true
11 
12                    if Player.leaderstats.Nature.Value == "Fire" then
13                game.ReplicatedStorage.ShootFireBall:FireServer()
14                    elseif Player.leaderstats.Nature.Value == "Grass" then
15            game.ReplicatedStorage.ShootGrassBall:FireServer()
View all 23 lines...

I forgot to end the if Player.leaderstats.Nature.Value == "Fire" then Lol

Answer this question