local SwimAnimation = Instance.new('Animation')
SwimAnimation.AnimationId = 'rbxassetid://5908030188'
RAnimation = Hum:LoadAnimation(SwimAnimation)
local IdleAnimation = Instance.new('Animation')
IdleAnimation.AnimationId = 'rbxassetid://5908001922'
LAnimation = Hum:LoadAnimation(IdleAnimation)
swimmingRightNow = false
while true do
wait()
if cam.CFrame.Y < -10 then
script.Parent.Frame.Visible = true
elseif cam.CFrame.Y > - 10 then
script.Parent.Frame.Visible = false
end
if char:WaitForChild("HumanoidRootPart").Position.Y <= -5 and swimmingRightNow == false then
swimmingRightNow = true
Swim:FireServer("Swim")
print("SwimmingRIghtNow is true")
elseif char:WaitForChild("HumanoidRootPart").Position.Y > -5 and swimmingRightNow then
swimmingRightNow = false
Swim:FireServer("NoSwim")
RAnimation:Stop()
LAnimation:Stop()
print("SwimmingRightnow is false")
end
end
I was wondering how to make the player play a swimming animation when the player is moving. When the player stops moving it plays an idle animation instead.