There's a problem with my local script inside this tool.If I use it everything works fine but once I change to another tool and back to this one, if I click it, everything happens twice.The more I change to another tool, the more times this happens.I've tried everything I could think of to stop this from happening but no result.If I'd use the tool when FE isn't enabled(Tool which would have the server script inside too of course) everything works smoothly.So I reckon I'm missing something since it doesn't work in FE. Here's the local script.No need for the server script since the problem is here. Thanks for your time.
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("Event1")
local bin = script.Parent
local modules = require(game.Workspace.ModuleScript)
local player = game.Players.LocalPlayer
spew = false
mouse = player:GetMouse()
IsEquipped = false
function onSelected(mouse)
IsEquipped = true
print("select")
mouse.Icon = "rbxasset://textures\\GunCursor.png"
bin.Activated:connect(function() onButton1Down(mouse) end)
bin.Deactivated:connect(function() onButton1Up(mouse) end)
end
function onButton1Down(mouse)
spew = true
while spew do
if not IsEquipped then return end
modules.Take(player, 1)
wait(.08)
mousehitp = mouse.Hit.p
RemoteEvent:FireServer(mousehitp)
end
end
function onButton1Up(mouse)
spew = false
end
bin.Unequipped:Connect(function()
IsEquipped = false
end)
bin.Equipped:connect(onSelected)

1 comment
Thank you so much! Been struggling for the last 2 hours, you're a life saver!