I have a problem with animation, for some reason its can’t stop playing while you press “Stop Animation” did i do something wrong?
here the code:
script.Parent.MouseButton1Click:Connect(function(player)
if script.Parent.Text == "Start Animation" then
local User = game.Players.LocalPlayer
local Character = User.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = script.Animation
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
EventStart:FireServer(player)
wait(1)
script.Parent.Text = "Stop Animation"
script.Parent.Visible = true
elseif script.Parent.Text == "Stop Animation" then
local User = game.Players.LocalPlayer
local Character = User.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = script.Animation
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Stop()
script.Parent.Visible = false
script.Parent.Text = "Start Animation"
EventEnd:FireServer(player)
end
end)
thanks for helping