local animation = Instance.new("Animation") animation.AnimationId = "http://roblox.com/Asset?ID=2017727992" local player = game.Players.LocalPlayer local char = player.Character if not player.Character then repeat wait () until player.Character end local animTrack = player.char.Humanoid:Load animation(animation) function touch(hit) animTrack:Play() end game.Workspace.Base.Touched:connect(touch)
What this is supposed to do is play a swimming animation when the player touches the ocean, in which Base in the workspace is the ocean, and yes it is a part. Nothing appears in the output log as an error, but the animation doesn't play. I even tested it with another part and it didn't work. I asked my friend who can script and he said the animation needs to the load the current character. As of now, I cant test any scripts so I have to be on mobile. I would appreciate any feedback.
LoadAnimation
, and Animation
was made lowercase. To fix this:local animTrack = char.Humanoid:LoadAnimation(animation)
Touched
event locally.-- Server script inside game.Workspace.Base local anim = Instance.new"Animation" anim.AnimationId = ""-- put your id here anim.Parent = script.Parent -- needs a parent, else can’t exist script.Parent.Touched:Connect(function(part) if part.Parent:FindFirstChild"Humanoid" then part.Parent.Humanoid:LoadAnimation(anim):Play() end end)