You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to have this modulescript work again once the ability is finished
What is the issue?
Once the ability is finished, it sets the “hasAbility” bool to false yet it doesn’t give the ability again
What solutions have you tried so far?
I’ve tried moving code, tried changing times, clueless on what it could be.
The issue is the same for all orbs so I’m going to send it just for one orb.
Module:
if hasAbility.Value == false then
local function countdown()
for i = abilityTime, 0, -1 do
abilityTime = i
timer.Text = i
wait(1)
end
end
if orbName == "RedOrb" then
orb:Destroy()
hasAbility.Value = true
doubleJumpGradient.Parent = bar
title.Text = "DOUBLE JUMP"
doubleJumpIcon.Visible = true
infoBG:TweenPosition(UDim2.new(0.007, 0,0.297, 0), "Out", "Linear", 0.4)
countdown()
title.Text = ""
doubleJumpIcon.Visible = false
infoBG:TweenPosition(UDim2.new(-1,0,.297,0), "Out", "Linear", 0.4)
wait(0.4)
hasAbility.Value = false
runGui.Visible = true
holder.Visible = false
infoBG.Visible = false
end
end
Script inside orb:
hitbox.Touched:Connect(function(hit)
if db == false then
local player
if game:GetService("Players"):FindFirstChild(hit.Parent.Name) then
player = game:GetService("Players"):WaitForChild(hit.Parent.Name)
module:DoAbility(orb, player, abilityTime)
db = true
end
end
end)
I’m clueless on why the script won’t repeat once the orb has been touched, please help.
Also, should I use TweenService instead of this method?
The variable “db” stands for debounce. This is the name of a pattern people use to make sure things don’t happen more than once, or that they don’t happen too quickly again.
where you set db = true, you’ll probably also want to wait(5) and then set db = false
No, because we don’t need the orb anymore as we’re just changing some gui things and a a couple variables and it works once but if i try it for another orb after the ability is finished, it no longer works. it used to work in the future. It broke ever since I added the gradient.
We destroy the orb before we can even set debounce to true anyway, I don’t want it firing multiple times. That’s why I have the debounce. Orbs are also cloned so the DB is there just for the specific orb which will be destroyed.
Not tried that yet, will try that but I’ve just got an infinite yield which I might have found my problem.
Infinite yield possible on 'Players.KBsully1.PlayerGui.Ability.Holder.Gradients:WaitForChild("DoubleJumpGradient")' (x22)
Because we don’t have our double jump gradient where it was when it was originally defined, then the script might be stopping because it cannot find it. I’ll try and fix it and see if it works then.