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?
Edit: Sorry for not putting the script here earlier. Here it is:
local player = game:GetService("Players").LocalPlayer
repeat wait() until player.Character
local char = player.Character
local mouse = player:GetMouse()
local func = script:WaitForChild("PunchFunc")
local PunchEnable = script.PunchEnable
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)
This is a local script that tells the remote "PunchFunc" to fire. Im trying to disable this script while a tool is equipped. PunchEnable is the bool value of the script, and i've already inserted a script into the tool that controls whether this value will be turned false or true depending if its unequipped or equipped. However as previously mentioned it does not work.

1 comment
Did my answer help you?