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

What's the best way to play an animation if clicked?

Asked by 4 years ago

I don't know how to play an animation when RMB is activated/ clicked. Please help. Thank you! <3

0
These types of questions is already asked in the dev forums. JesseSong 3916 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
--LocalScript
local plr = game.Players.LocalPlayer;
local mouse = plr:GetMouse() --we got the mouse
local ID = "put id of animation here" --make sure you only put the numbers

mouse.Button2Up:Connect(function() --When we right click
    local anim = Instance.new("Animation") --makes an animation
    anim.AnimationId = "rbxassetid".. tostring(ID) --sets the ID
    local track = plr.Character.Humanoid:LoadAnimation(anim) --loads the track to the player's humanoid
    track:Play() --plays the animation
end)

Please make an attempt to solve your problem, this isn't a request site.

1
I don't understand why people keep on telling me that even though all I'm trying to do is to learn by giving myself challenges. "I'm trying my hardest to learn!" :( Thank you anyways. Inciney 7 — 4y
0
No worries, I just got the idea you went around asking for scripts based on your reputatation. Utter_Incompetence 856 — 4y
Ad

Answer this question