Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

1 comment

0

Should be Button1Down and Button1Up not MouseButton1Down and Up

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.