Hey, I ran into an issue while trying to make a campfire system using a proximity prompt, for some reason the looped sitting animation is being played 3x on the humanoid, the elseif function works fine, but it only stops the animation once, meaning the player would still have 2 sitting animations playing on loop. I tried to avoid it by adding a debounce, but it didn’t help at all.
Below you can see the code:
local SS = game.ServerStorage
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function(Player)
local PlayerData = SS.PlayerData[Player.Name]
local Track = Instance.new("Animation")
local Anim = Player.Character.Humanoid:LoadAnimation(Track)
Track.AnimationId = "rbxassetid://8736821774"
local UI = script.Campfire:Clone()
local Debounce = true
if Player and Player.Character then
if PlayerData and not Player.Character:FindFirstChild("Deactivate") and Debounce then
Debounce = false
ProximityPrompt.MaxActivationDistance = 10
Player.Character.HumanoidRootPart.CFrame = CFrame.lookAt(Player.Character.HumanoidRootPart.Position,script.Parent.Parent.Position)
Player.Character.Humanoid.AutoRotate = false
Player.Character.Humanoid.JumpPower = 0
Player.Character.Humanoid.WalkSpeed = 0
Anim:Play(.25)
local anims = Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()
local Deactivate = Instance.new("Folder")
Deactivate.Name = "Deactivate"
Deactivate.Parent = Player.Character
UI.Parent = Player.PlayerGui
UI.Enabled = true
elseif Player.Character:FindFirstChild("Deactivate") then
Player.PlayerGui:FindFirstChild("Campfire"):Destroy()
Player.Character:FindFirstChild("Deactivate"):Destroy()
ProximityPrompt.MaxActivationDistance = 7
local anims = Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()
for _,v in pairs(anims) do
print(anims)
end
Anim:Stop(.25)
Player.Character.Humanoid.AutoRotate = true
Player.Character.Humanoid.JumpPower = 50
Player.Character.Humanoid.WalkSpeed = 16
Debounce = true
end
end
end)
This is how I figured out how many animations are being played on the character:
Yes I have, I think the Anim:Stop(.25) doesn’t stop the animation for some reason.
Cause every time I use the proximity prompt, the print keeps adding one or two more animations to the list.
( This is how the print looks like after using the proximity prompt 3 times )
local SS = game.ServerStorage
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function(Player)
local PlayerData = SS.PlayerData[Player.Name]
local Track = Instance.new("Animation")
local Anim = Player.Character.Humanoid.Animator:LoadAnimation(Track)
Track.AnimationId = "rbxassetid://8736821774"
local UI = script.Campfire:Clone()
local Debounce = true
if Player and Player.Character then
if PlayerData and not Player.Character:FindFirstChild("Deactivate") and Debounce then
Debounce = false
ProximityPrompt.MaxActivationDistance = 10
Player.Character.HumanoidRootPart.CFrame = CFrame.lookAt(Player.Character.HumanoidRootPart.Position,script.Parent.Parent.Position)
Player.Character.Humanoid.AutoRotate = false
Player.Character.Humanoid.JumpPower = 0
Player.Character.Humanoid.WalkSpeed = 0
Anim:Play(.25)
local anims = Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()
local Deactivate = Instance.new("Folder")
Deactivate.Name = "Deactivate"
Deactivate.Parent = Player.Character
UI.Parent = Player.PlayerGui
UI.Enabled = true
elseif Player.Character:FindFirstChild("Deactivate") then
Player.PlayerGui:FindFirstChild("Campfire"):Destroy()
Player.Character:FindFirstChild("Deactivate"):Destroy()
ProximityPrompt.MaxActivationDistance = 7
local anims = Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()
for _,v in pairs(anims) do
print(anims)
end
Anim:Stop(.25)
Player.Character.Humanoid.AutoRotate = true
Player.Character.Humanoid.JumpPower = 50
Player.Character.Humanoid.WalkSpeed = 16
Debounce = true
end
end
end)
local SS = game.ServerStorage
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function(Player)
local PlayerData = SS.PlayerData[Player.Name]
local Char = Player.Character
local Track = Instance.new("Animation")
Track.AnimationId = "rbxassetid://8736821774"
Track.Parent = Char
local Anim = Player.Character.Humanoid.Animator:LoadAnimation(Track)
local UI = script.Campfire:Clone()
local Debounce = true
if Player and Player.Character then
if PlayerData and not Player.Character:FindFirstChild("Deactivate") and Debounce then
Debounce = false
ProximityPrompt.MaxActivationDistance = 10
Player.Character.HumanoidRootPart.CFrame = CFrame.lookAt(Char:FindFirstChild("HumanoidRootPart").Position,script.Parent.Parent.Position)
Player.Character.Humanoid.AutoRotate = false
Player.Character.Humanoid.JumpPower = 0
Player.Character.Humanoid.WalkSpeed = 0
Anim:Play(.25)
local anims = Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()
local Deactivate = Instance.new("Folder")
Deactivate.Name = "Deactivate"
Deactivate.Parent = Player.Character
UI.Parent = Player.PlayerGui
UI.Enabled = true
elseif Player.Character:FindFirstChild("Deactivate") then
Player.PlayerGui:FindFirstChild("Campfire"):Destroy()
Player.Character:FindFirstChild("Deactivate"):Destroy()
ProximityPrompt.MaxActivationDistance = 7
local anims = Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()
for _,v in pairs(anims) do
v:Stop()
end
Anim:Stop(.25)
Player.Character.Humanoid.AutoRotate = true
Player.Character.Humanoid.JumpPower = 50
Player.Character.Humanoid.WalkSpeed = 16
Debounce = true
end
end
end)