if you can can you send me the code of it
Hello,
There are a variety of ways to check for a player’s click, however the best option is to use UserInputService
. However it only works in LocalScripts
, so that’s what the script will need to be.
Basically you check when a player begins input (e.g. starts holding down a key), then check what type of input they are doing.
local UserInputService = game:GetService("UserInputService") local Tool = script.Parent UserInputService.InputBegan:Connect(function(InputObject) if InputObject.UserInputType == Enum.UserInputType.MouseButton1 then -- play animation end end)
How it works is you use theLoadAnimation
method found in Humanoid
, giving it the Animation
object that has the AnimationId
and other data.
This method returns an AnimationTrack
object that you can use to control the animation – play it, stop it etc.
Here’s an example:
local Player = game.Players.LocalPlayer -- this also only works in LocalScripts local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Animation = Instance.new("Animation") -- create a new animation object Animation.AnimationId = "rbxassetid://00000" -- put your animation id over the zeroes local Track = Humanoid:LoadAnimation(Animation) Track:Play() Track:Stop()
Closed as Not Constructive by gitrog, Void_Frost, alphawolvess, and green271
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?