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

How can I make this animation on this tool a Click animation on a mouse?

Asked by
dog6779 25
7 years ago
Edited 7 years ago

So here is the script:

01local animation = Instance.new("Animation")
02animation.AnimationId = "https://www.roblox.com/Asset?ID=1438749801"
03 
04local trackanimation = nil
05local playability = true
06function playAnimation(AnimationSource)
07    if playability == true then
08        local plr = game.Players.LocalPlayer
09        trackanimation = plr.Character.Humanoid:LoadAnimation(animation)
10 
11          trackanimation.KeyframeReached:connect(function()
12            print ('Working')
13        end)
14        trackanimation:Play()
15    end
View all 26 lines...

But how do I make it where it shows up in the game and How do I make it where it's only a Mouse click. This script only when you pull out the tool it starts the animation.

1 answer

Log in to vote
0
Answered by 7 years ago
01-- make sure the change the animationId value in the tool!
02wait(0.5)
03local Tool = script.Parent
04local AnimationId = Tool.AnimationId.Value
05local Player = game.Players.LocalPlayer
06local Character = Player.Character or Player.CharacterAdded:Wait()
07local Humanoid = Character:WaitForChild("Humanoid")
08local Cooldown = false
09local Animation = Instance.new("Animation")
10Animation.AnimationId = "rbxassetid://"..AnimationId
11Animation.Parent = Humanoid
12Tool.Activated:Connect(function()
13    local Anim = Humanoid:LoadAnimation(Animation)
14    Anim:Play()
15end) -- put a IntValue in the tool and name it AnimationId then just paste the id of the animation you want in the IntValue number label.
0
Okay, so the script you gave me is working but when I saw this in the script analysis it said this: W003: (9,5) Global 'y' is only used in the enclosing function; consider changing it to local. W003: (10,5) Global 'z' is only used in the enclosing function; consider changing it to local. dog6779 25 — 7y
Ad

Answer this question