So I have this script that keeps timing out, and I tried everything using the “dog == false”
dog = false
local player = game.Players.LocalPlayer
repeat wait(1) until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Name = "Idle"
animation.Parent = script.Parent
animation.AnimationId = "http://www.roblox.com/asset/?id=" .. "4376204956"
rat = false
local animtrack = humanoid:LoadAnimation(animation)
script.Parent.Equipped:connect(function()
animtrack:Play()
rat = true
end)
script.Parent.Unequipped:connect(function()
animtrack:Stop()
end)
while true do
if rat == true and dog == false then
dog = true
wait(120)
script.Parent.ColdGiver:FireServer()
end
end
Your while loop will only yield if the if statement passes, overwise it’s repeating too quickly causing a timeout.
I recommend putting a wait() or something to yield inside.
Eg.
while true do
if rat and not dog then
dog = true
wait(120)
script.Parent.ColdGiver:FireServer()
end
wait()
end
dog = false
local player = game.Players.LocalPlayer
repeat wait(1) until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Name = "Idle"
animation.Parent = script.Parent
animation.AnimationId = "http://www.roblox.com/asset/?id=" .. "4376204956"
rat = false
local animtrack = humanoid:LoadAnimation(animation)
script.Parent.Equipped:connect(function()
animtrack:Play()
rat = true
end)
script.Parent.Unequipped:connect(function()
animtrack:Stop()
end)
while true do
if rat == true and dog == false then
dog = true
wait(120)
script.Parent.ColdGiver:FireServer()
end
end
dog = false
local player = game.Players.LocalPlayer
repeat wait(1) until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Name = "Idle"
animation.Parent = script.Parent
animation.AnimationId = "http://www.roblox.com/asset/?id=" .. "4376204956"
rat = false
local animtrack = humanoid:LoadAnimation(animation)
script.Parent.Equipped:connect(function()
animtrack:Play()
rat = true
end)
script.Parent.Unequipped:connect(function()
animtrack:Stop()
end)
while true do
wait()
if rat == true and dog == false then
dog = true
wait(120)
script.Parent.ColdGiver:FireServer()
end
end
DevConX is asking for a screenshot with the line numbers on the left side, we can’t tell what line 29 is the script itself as easily (for future reference)
Though it does appear to be that if rat isn’t true or dog isn’t false, it’s basically a while true do loop which would cause a timeout; the script would run as fast as it possibly can indefinitely, leaving no time for anything else to happen, hence a timeout.