Hi! I seem to have this problem where i have a local to server event to play an animation, but the :Stop() isnt working for the animation, however, the :Play() is. I also just wanna say that ive tried switching the :Play() And :Stop() to a local script (which didnt work) but i still need to event to run some other code anyways, after a bit of debugging I realized that the problem was the :Stop() (As mentioned before), not the server event or anything else (I Hope)
Provide an overview of:
- What does the code do and what are you not satisfied with?
my code is a block script and the animation is starting but not ending with :Stop() - What potential improvements have you considered?
Ive tried switching the :Play() and :Stop() to a local script - How (specifically) do you want to improve the code?
Simple just make the :Stop work
The Local Script:
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local blockevent = script.Parent.BlockEvent
local unblockevent = script.Parent.UnBlockEvent
uis.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.F then
blockevent:FireServer()
end
end)
uis.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.F then
unblockevent:FireServer()
end
end)
The Server Script:
llocal uis = game:GetService("UserInputService")
local blockevent = script.BlockEvent
local unblockevent = script.UnBlockEvent
local blockanim = script.BlockAnim
blockevent.OnServerEvent:Connect(function(player)
local humanoid = player.Character.Humanoid
local animationTrack = humanoid:WaitForChild("Animator"):LoadAnimation(blockanim)
animationTrack:Play()
end)
unblockevent.OnServerEvent:Connect(function(player)
local humanoid = player.Character.Humanoid
local animationTrack = humanoid:WaitForChild("Animator"):LoadAnimation(blockanim)
animationTrack:Stop()
end)