I’m trying to make a taunt menu. There are 2 types of taunts in my game, the looping ones and the non-looping ones. I want the stopping system to change depending on whether or not they loop. For some reason, the looping animations are still registered as having .Looped
disabled, though it is not.
Script:
local StarterGui = game:GetService("StarterGui")
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local AnimFolder = script.Parent.Anims
local Taunting = script.Parent.Parent.Taunting
local connection
local CanTaunt = true
local CurrAnim
local TauntSound
for i, v in pairs(script.Parent.Main:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Down:Connect(function()
local TauntRequested = v.Name
local SearchForTauntInLibrary = AnimFolder:FindFirstChild(TauntRequested)
if SearchForTauntInLibrary ~= nil and CanTaunt then
print("search succeeded")
if CurrAnim ~= nil then
CurrAnim:Stop()
end
CurrAnim = player.Character.Humanoid.Animator:LoadAnimation(SearchForTauntInLibrary)
CurrAnim:Play()
if CurrAnim.Looped == true then
print("loopinganim")
Taunting.Value = true
script.Parent.Visible = false
player.Character.Humanoid.WalkSpeed = 0
if SearchForTauntInLibrary:FindFirstChild("IsMovingTaunt") then
local sound = Instance.new("Sound")
sound.Name = ("TauntSound")
sound.SoundId = 'rbxassetid://9767287320'
sound.Looped = true
sound.RollOffMaxDistance = 250
sound.RollOffMode = Enum.RollOffMode.InverseTapered
sound.Parent = player.Character:FindFirstChild("HumanoidRootPart")
sound:Play()
end
connection = UIS.JumpRequest:Connect(function()
print("jrequest")
if CurrAnim.IsPlaying then
print("succeed")
if player.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("TauntSound") then
player.Character.HumanoidRootPart.TauntSound:Destroy()
end
CurrAnim:Stop()
player.Character.Humanoid.WalkSpeed = 16
Taunting.Value = false
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
connection:Disconnect()
end
end)
elseif CurrAnim.Looped == false then
print("nonloop")
Taunting.Value = true
player.Character.Humanoid.WalkSpeed = 0
script.Parent.Visible = false
player.CameraMinZoomDistance = 8
CurrAnim.Stopped:Wait()
player.Character.Humanoid.WalkSpeed = 16
Taunting.Value = false
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
player.CameraMinZoomDistance = 0.5
end
end
end)
end
end
player.Character:WaitForChild("Humanoid").Died:Connect(function()
print("Player has died; taunt logic stopping.")
CurrAnim:Stop()
CanTaunt = false
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
if player.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("TauntSound") then
player.Character.HumanoidRootPart.TauntSound:Destroy()
end
end)
Any help would be much appreciated!