I have checked if it runs before or after, and it only runs before. It should wait one second, and then run the next code. But it doesn’t AHSDfvgt3eauhe
I can fix this with other methods but I just want to know why the code isn’t running.
Are you wrapping this code in something else? Like a method or a function? I believe there are methods/functions where if you include a delay it would break it
Deb = workspace.Stuff.Cooldowns
Battler = script.Parent.Parent.Battler
Plr = script.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
if Deb:FindFirstChild(script.Parent.Parent.Battler.Value).Value == false then
workspace.Stuff.Cooldowns.Change:Fire(Deb:FindFirstChild(script.Parent.Parent.Battler.Value), true)
local Team = nil
local Waittime = Deb:FindFirstChild(script.Parent.Parent.Battler.Value).Length.Value
if Plr.TeamColor == BrickColor.new("Really red") then
Team = "Red"
elseif Plr.TeamColor == BrickColor.new("Bright blue") then
Team = "Blue"
else
error("You have to be on blue or red to use this battler.")
end
local BattlerName = (Team..""..Battler.Value)
task.wait()
local Morph = game.ServerStorage.Morphs:FindFirstChild(Team):FindFirstChild(Team..""..Battler.Value)
task.spawn(function()
workspace.Stuff.MorphHandler.Event:Fire(Plr, Morph, Battler.Value, Team)
end)
task.wait(1)
workspace.Stuff.Cooldowns.Change:Fire(Deb:FindFirstChild(script.Parent.Parent.Battler.Value), false)
end
end)
It is a serverscript located in PlayerGui. It sends a notice to a BindableEvent (Change) in workspace. The event runs the first time it is called upon before task.wait, but not the second.
To be honest, I’m not sure what’s going on here maybe someone else can see it but I do have an alternative solution (Doesnt relate to the issue but solves it).