Everything in my scripts works (including the animation) but for some reason the animation track won’t stop when i tell it to.
–Here’s The Script
local UIS = game:GetService("UserInputService")
local weld = Instance.new("Weld")
local swinging = false
local function onSwingEvent(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
-- Load the animation only once
local animation = game.ReplicatedStorage:FindFirstChild("SwingAnimation")
if not animation then
animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://18263356301"
animation.Name = "SwingAnimation"
animation.Parent = game.ReplicatedStorage
end
local animTrack = animator:LoadAnimation(animation)
if not swinging then
char.PrimaryPart.CFrame = game.Workspace.Cylinder.CFrame * CFrame.new(0, 10, 0)
weld.Part0 = game.Workspace.Cylinder
weld.Part1 = char.PrimaryPart
weld.Parent = char
weld.C1 = CFrame.new(0, 2, 0)
animTrack:Play()
swinging = true
else
weld.Parent = game.ReplicatedStorage
task.wait(0.1)
animTrack:Stop()
swinging = false
end
end
game.ReplicatedStorage.SwingEvent.OnServerEvent:Connect(onSwingEvent)