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)
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)
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)