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

How to efficiently fix this tool be animated on Mouse Hold?

Asked by
xPolarium 1388 Moderation Voter
9 years ago

So I have a tool, a pickaxe rather, that I need it to perform a "Mining" animation when the player holds their Mouse Button down. Basically how it would look like if you were mining in Minecraft. I have this script that I did to experiment on it but I can't figure how to change it back to the original position and then back to the new UNTIL the player stops hold left click. All I need is, is there a efficient way to animate a tool or fix my script? I'm using the tool object property,GripForward to do this which I doubt is the best way. I tried Roblox's Animation Editor but that only works for Humanoids(?).

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:connect(function()
    script.Parent.GripForward = Vector3.new(0, 2, -1)
    --Doing this changes the tool to a 45 degree angle.



end)

2 answers

Log in to vote
0
Answered by 9 years ago

Using a while loop:

local Holding = false
local Mouse = Game.Players.LocalPlayer:GetMouse()
Mouse.MouseButton1Down:connect(function()
    Holding = true
    while Holding and wait() do
        print("Player is holding mouse button")
        --Change grip
    end
        print("Player is not holding mouse button")
        --Return tool to normal
end)
Mouse.MouseButton1Up:connect(function()
    Holding = false
end)
0
Should be Button1Down and Button1Up not MouseButton1Down and Up DOGEDOGDOGGIE 2 — 6y
Ad
Log in to vote
-3
Answered by 9 years ago

trying this untested have no idea if it will actually even work :p

local mouse = game.Players.LocalPlayer:GetMouse()

while mouse.Button1Down do mouse.Button1Down:connect(function()
    script.Parent.GripForward = Vector3.new(0, 2, -1)
    --Doing this changes the tool to a 45 degree angle.



end)

Answer this question