If you sprint and start climbing on a Truss, you'll have increased walk speed. So whenever you sprint on the Truss, you have a different animation. Here's what I've got:
local player = game.Players.LocalPlayer repeat wait() until player.Character.Humanoid local humanoid = player.Character.Humanoid
game.Workspace.Truss.Touched:Connect(function(p)
if player.Character.Humanoid.WalkSpeed == 60 then
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=3454180452"
end
end)
Please help!
From what I can tell, you're trying to use a Touched
event for a Local Script
. This won't work because touched events won't fire from the local script. You can set up the touched event from a server script. You don't need a local script because Humanoid:LoadAnimation()
Here is a written example:
This should be your server script.NOT a local script. Also, for this example, you would want to create a new Animation inside of the script. Remember to change the ID.
local animation script:WaitForChild("Animation") script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Just if you need the player. local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local humanoid_animation = humanoid:LoadAnimation(animation) humanoid_animation:Play() end end)