Im trying to temporarily disable a mouse button punching script once the player selects a tool. But when I tried script.Disabled the script still runs. Then I tried adding a bool value to the script, and when the tool is equipped the value will turn false, which should not let the script run. However the script runs regardless. Is there another way?
Here is the local script im trying to "disable"
local player = game:GetService("Players").LocalPlayer
repeat wait() until player.Character
local char = player.Character
local mouse = player:GetMouse()
local func = script:WaitForChild("PunchFunc") --the remote event
local PunchEnable = script.PunchEnable-- bool value
local enabled = true
local tapped = false
mouse.Button1Down:Connect(function()
if enabled == true and PunchEnable.Value == true then
enabled = false
func:FireServer("Combat", "Left")
wait()
enabled = true
end
end)
mouse.Button2Down:Connect(function()
if not tapped then
tapped = true
wait(0.3)
tapped = false
else
if enabled == true and PunchEnable.Value == true then
enabled = false
func:FireServer("Combat", "Right")
wait()
enabled = true
end
end
end)
The script that actually handles the punches instead of firing the remote is a child of the remote event "PunchFunc".
