Just before you play the animation, set the walk speed and jump power to 0.
local tool = script.Parent
local client = game:GetService("Players").LocalPlayer
local canUse = true
local animation
local connection
tool.Equipped:Connect(function(Mouse)
connection = Mouse.Button2Down:Connect(function()
if canUse then
local humanoid = client.Character.Humanoid
canUse = false
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
animation = humanoid:LoadAnimation(tool.Heavy1)
animation:Play()
wait(3)
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
canUse = true
end
end)
end)
tool.Unequipped:Connect(function()
local humanoid = client.Character.Humanoid
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
animation:Stop()
connection:Disconnect()
end)
The default WalkSpeed is 16, where the default JumpPower is 50. You can also notice the predeclared animation and connection variables. The animation variable is there so that you do not need to use a global variable. The usage of global variables is bad practice, they make your code base a mess.
The animation variable is instead available as an upvalue (external local variable) in the event listeners, and I disconnect connections since your Button2Down event listener is nested in your Equipped event listener, which means new connections are being created each time you equip the tool.
1 comment
if you're looking to completely disable movement, you can disable the ControlScript