i need to stop a function but idk what to do here’s what i’ve done so far:
local RunService = game:GetService("RunService")
local deer = script.Parent
local humanoid = deer:FindFirstChildWhichIsA("Humanoid")
local rootPart = deer:FindFirstChild("HumanoidRootPart")
local Animations = deer.Animations
local Values = deer.Values
local Idle = humanoid.Animator:LoadAnimation(Animations.Idle)
local Walk = humanoid.Animator:LoadAnimation(Animations.Walk)
local Charge = humanoid.Animator:LoadAnimation(Animations.Charge)
local PosX, PosY, PosZ
local Deer_Groan = rootPart.Deer_Groan
local Deer_Angry = rootPart.Deer_Angry
local PlaybackSpeed
--Functions--
function FindPlaybackSpeed(oldSpeed)
local Speed = math.random(2, 4) / 3
print(oldSpeed, Speed)
if Speed == oldSpeed then
return FindPlaybackSpeed(oldSpeed)
else
return Speed
end
end
function SoundsLoop()
while RunService.Stepped:Wait() do
local PlaybackSpeed = FindPlaybackSpeed(Deer_Groan.PlaybackSpeed)
Deer_Groan.PlaybackSpeed = PlaybackSpeed
Deer_Groan:Play()
Deer_Groan.Ended:Wait()
wait(math.random(5, 10))
--wait(0.5)
end
end
--[[local WalkCycle =
wait(math.random(3, 5))
Idle:Stop()
wait(0.1)
Walk:Play()
PosX = rootPart.Position.X + math.random(-5, 5)
PosY = rootPart.Position.Y + math.random(-5, 5)
PosZ = rootPart.Position.Z + math.random(-5, 5)
humanoid:MoveTo(Vector3.new(PosX, PosY, PosZ))
humanoid.MoveToFinished:Wait()
Idle:Play()
wait(0.1)
Walk:Stop()
end)]]--
function FindPlayersInRange()
WalkCycle:Disconnect()
end
--Calling Functions--
coroutine.wrap(SoundsLoop)()
coroutine.wrap(WalkCycle)()
wait(5)
coroutine.wrap(FindPlayersInRange)()
i don’t really have much information…
![]()