Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why does my FE part dropper drop an extra part every time i re equip it?

i am slowly making my way to creating a FE compatible gun. i started off with a basic block that when you click, drops a block right on the ground. it works perfectly, the only problem is, when i unequip and equip my tool, it drops an extra part. the server script is located in serverScriptService. the localscript is located in the tool itself. here are my scripts.

LocalScript:

local plr = script.Parent.Parent.Parent
local tool = script.Parent
local Handle = tool.Handle
local mouse = plr:GetMouse()

tool.Equipped:connect(function()
	mouse.Button1Down:connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer()
	end)
end)

Server Script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:connect(function(plr)
	local tool = plr.Character.Tool
	local Handle = tool.Handle
	local Part = Instance.new("Part", game.Workspace)
	Part.CFrame = Handle.CFrame
	wait(3)
	Part:Destroy()
	
end)

here is what happens when it adds another part: here is what happens when it adds another part

1 answer

✓ Accepted answer

You could disconnect the event when you unequip the tool, or you can use the Activated event. It fires when you click while you are holding it. You can also remove the remote and have this on the server.

tool.Activated:Connect(function()
    local tool = plr.Character.Tool
    local Handle = tool.Handle
    local Part = Instance.new("Part", game.Workspace)
    Part.CFrame = Handle.CFrame
    wait(3)
    Part:Destroy()
end)

assuming tool is defined.

Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.