Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Change run animation with the click of a GUI button?

Asked by 6 years ago
Edited 6 years ago

This is the script I have right now, but it doesn't change the run animation when clicked. What am I doing wrong?

script.Parent.MouseButton1Click:connect(function(p)
p.Character.Animate.run.RunAnim.AnimationId = "http://www.roblox.com/asset?id=1889592040"
end)
0
have it do the animation from the Humanoid instead of the Character because the Humanoid controls animations for the Character not the Character itself DeceptiveCaster 3761 — 6y
0
How would I do that? Change "Character" to "Humanoid" in the script? felonymartinez 12 — 6y
0
p.Character.Humanoid.RunAnim.AnimationId i think DeceptiveCaster 3761 — 6y
0
Doesn't work :/ felonymartinez 12 — 6y
View all comments (3 more)
0
hmmm DeceptiveCaster 3761 — 6y
0
have it check for Humanoid.Running then change the ID DeceptiveCaster 3761 — 6y
0
How would I do that?local h = p.Parent:FindFirstChild('Humanoid') if h then ? felonymartinez 12 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset?id=1889592040"
script.Parent.MouseButton1Click:connect(function()
local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation)
animTrack:Play()
end)

I stole the scripting from the Roblox wiki, so I'm not 100% sure it'll work.

1
Gives an error on the last " mark, not sure what I'm supposed to put inside those last parantheses? felonymartinez 12 — 6y
0
Oops, just remove the last quotation mark. protectiveebob 221 — 6y
1
the animation does not have a Parent you idiot xD DeceptiveCaster 3761 — 6y
0
I don't think it needs a .Parent protectiveebob 221 — 6y
0
It does need a Parent in order to be created. DeceptiveCaster 3761 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

I fixed it, this should work:

script.Parent.MouseButton1Click:connect(function(p)
local AnimationId = "1889592040" --set animation id here
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://"..AnimationId
local k = p.Character.Humanoid:LoadAnimation(Anim)
k:Play()
k:AdjustSpeed(2) --set animation speed here
end)

Tell me if it's broken or not.

0
MouseButton1Click doesn't return anything, so you have to use localplayer protectiveebob 221 — 6y

Answer this question