I made a script for swimming and its saying "LoadAnimation is not a valid member of Part" when ever I touch the Part named Water this is the script:
function Swimming(player,Humanoid) local animation=Instance.new("Animation") animation.AnimationId="http://www.roblox.com/Asset?ID=1010301459" local animTrack=player:LoadAnimation(animation) animTrack:Play() print "going to swim this player on:" local debounce=false if debounce==false then debounce = true print(player.Model.Name) script.Parent=workspace.Water end end script.Parent.Touched:Connect(Swimming)
this is the first animation script I made, what I want it to do is play my animation when ever I touch the scripts parent but the error I get in the output is "LoadAnimation is not a valid member of Part" please help me fix this.thx
local debounce = false -- debounce needs to be outside or else it will be set to false every time the function runs function Swimming(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) -- checks if limb touched by getting the player from its character if player then if debounce == false then local animation = Instance.new("Animation") -- loads animation animation.AnimationId = "http://www.roblox.com/Asset?ID=1010301459" animation.Parent = player.Character.Humanoid -- sets animation parent to humanoid local animTrack = player.Character.Humanoid:LoadAnimation(animation) --loads anim debounce = true --sets db to true animTrack:Play() -- plays print("swimming player: " .. player.Character.Name) -- prints "swimming player: creeperhunter76" wait(4) end debounce = false end end script.Parent.Touched:Connect(Swimming)