What do you want to achieve? I wanna play “cooldownAnimTrack” if the “IsAttacking” bool value is false after it was true . i also want to play “animTrackCharge” if “IsCharging” is true and after task.wait(chargeTime) “IsCharging” should be false and “IsAttacking” should be true.
What is the issue? every time i try to do something like that, it doesn’t work
What solutions have you tried so far? Many.
Here’s my script (i know this is very bad script don’t judge me):
if config:FindFirstChild("OverloadTime") and config:FindFirstChild("OverloadMaxTime") and config:FindFirstChild("ChargeTime") then
-- Sounds --
local cooldownSound = newTower.HumanoidRootPart:WaitForChild("CooldownSound")
local EndSound = newTower.HumanoidRootPart:WaitForChild("EndSound")
local EmptySound = newTower.HumanoidRootPart:WaitForChild("Empty")
local StartSound = newTower.HumanoidRootPart:WaitForChild("Start")
-- Humanoid --
local hum = newTower:FindFirstChild("Humanoid")
-- Overload Variables --
local overloadTime = config.OverloadTime.Value
-- Charge Variables --
local chargeTime = config.ChargeTime.Value
-- Animation Tracks --
local chargeAnimation = newTower.Animations:FindFirstChild("Charge")
local cooldown = newTower.Animations:FindFirstChild("Cooldown")
local animTrackCharge = hum:LoadAnimation(chargeAnimation)
local cooldownAnimTrack = hum:LoadAnimation(cooldown)
-- Other --
local IsCharging = config.IsCharging.Value
local IsAttacking = config.IsAttacking.Value
IsCharging = false
IsAttacking = false
if overloadTime <= 0 then
print("Overloading!")
cooldownAnimTrack:Play()
EndSound:Play()
task.wait(1)
EmptySound:Play()
task.wait(config.OverloadCooldown.Value)
IsCharging = true
IsAttacking = false
StartSound:Play()
animTrackCharge:Play()
task.wait(chargeTime)
config.OverloadTime.Value = config.OverloadMaxTime.Value
IsCharging = false
else
config.OverloadTime.Value -= 1
end
end
Tsk, tsk, tsk! What an AMATEUR MISTAKE!
So, the issue here is quite obvious.
You are indeed NOT setting the bool values to anything in your script. This is due to a simple, overlooked mistake that many people make, so do not be ashamed.
Because you still have no clue due to my pointless riffraff, let me explain it to you:
You have set the variables, as shown here:
To the Value Property.
This means that the IsCharging Variable is currently set to, none other than… A NUMBER!
So, whenever you are changing this variable, all you achieve is changing the variable to another value, leaving the outside instanced value COMPLETLY UNTOUCHED!
To fix this novice mistake, you simply need to rephrase your variables so that it’s not set to a value, and then changing the Instance.Value to the value you want.
Yes,. yes, you’ve tolerated my backlash enough… Here’s the solution had you still been confused:
if config:FindFirstChild("OverloadTime") and config:FindFirstChild("OverloadMaxTime") and config:FindFirstChild("ChargeTime") then
-- Sounds --
local cooldownSound = newTower.HumanoidRootPart:WaitForChild("CooldownSound")
local EndSound = newTower.HumanoidRootPart:WaitForChild("EndSound")
local EmptySound = newTower.HumanoidRootPart:WaitForChild("Empty")
local StartSound = newTower.HumanoidRootPart:WaitForChild("Start")
-- Humanoid --
local hum = newTower:FindFirstChild("Humanoid")
-- Overload Variables --
local overloadTime = config.OverloadTime.Value
-- Charge Variables --
local chargeTime = config.ChargeTime.Value
-- Animation Tracks --
local chargeAnimation = newTower.Animations:FindFirstChild("Charge")
local cooldown = newTower.Animations:FindFirstChild("Cooldown")
local animTrackCharge = hum:LoadAnimation(chargeAnimation)
local cooldownAnimTrack = hum:LoadAnimation(cooldown)
-- Other --
local IsCharging = config.IsCharging
local IsAttacking = config.IsAttacking
IsCharging.Value = false
IsAttacking.Value = false
if overloadTime <= 0 then
print("Overloading!")
cooldownAnimTrack:Play()
EndSound:Play()
task.wait(1)
EmptySound:Play()
task.wait(config.OverloadCooldown.Value)
IsCharging.Value = true
IsAttacking.Value = false
StartSound:Play()
animTrackCharge:Play()
task.wait(chargeTime)
config.OverloadTime.Value = config.OverloadMaxTime.Value
IsCharging.Value = false
else
config.OverloadTime.Value -= 1
end
end