So I’m trying to make a pixaxe from the game “Minecraft” if you don’t know what it is, it can mine stuff and I made it play an animation when you hold your mouse down and then stop when you lift it but it keeps playing (Animation is looped btw) This is the script:
local mouse = game.Players.LocalPlayer:GetMouse()
local db = false
script.Parent.Activated:Connect(function()
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char.Humanoid
local anim = hum:LoadAnimation(script.Parent.MiningAnim)
mouse.Button1Down:Connect(function()
if not db then
db = true
anim:Play()
script.Parent.Mining.Value = true
script.Parent.RemoteEvent:FireServer(mouse.Target)
print(script.Parent.Mining.Value)
wait(1)
db = false
end
end)
mouse.Button1Up:Connect(function()
if not db then
db = true
anim:Stop()
script.Parent.Mining.Value = false
print(script.Parent.Mining.Value)
wait(1)
db = false
end
end)
end)
If anyone could help me I would be very grateful and I hope you have a great day everyone! ;D