I am trying to an animation that plays on non-humanoid, and I want it to play at the moment when player touches a part. I have borrowed a scrupt from official roblox developer site and just added a few lines to play the anim. when a part is touched because by default the anim. played on the game start. As you may tell, it doesnt work for some reason. There were no errors and nothing in the output, and yes, I have my objectvalue set. Here are the lines a added:
local rig = script.Parent local PlayOnPartTouch = script:FindFirstChild("PlayOnPartTouch") local Character = Player.Character or Player.CharacterAdded:Wait if PlayOnPartTouch then local part = script.PlayOnPartTouch.Value if part and part:IsA("BasePart") then part.Touched:Connect(function(hit) if hit.Parent == Player.Character then kickAnimationTrack:Play() end end) end PlayOnPartTouch:Destroy() end
here is the whole script I am using:
local rig = script.Parent local PlayOnPartTouch = script:FindFirstChild("PlayOnPartTouch") local Character = Player.Character or Player.CharacterAdded:Wait() local humanoid = rig:FindFirstChildOfClass("Humanoid") if humanoid then humanoid:Destroy() end local kickAnimation = Instance.new("Animation") kickAnimation.AnimationId = "rbxassetid://7151528089" local animController = Instance.new("AnimationController") animController.Parent = rig local animator = Instance.new("Animator") animator.Parent = animController local kickAnimationTrack = animator:LoadAnimation(kickAnimation) if PlayOnPartTouch then local part = script.PlayOnPartTouch.Value if part and part:IsA("BasePart") then part.Touched:Connect(function(hit) if hit.Parent == Player.Character then kickAnimationTrack:Play() end end) end PlayOnPartTouch:Destroy() end kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString) print(paramString) end)
Screenshot of explorer window: https://imgur.com/Rc1VxxG