Hi, I’ve seen a lot of tool models written like this and I was wondering if this is really necessary for tools. If you know anything about it, please let me know!
local gun = script.Parent local re = script.Parent:WaitForChild("RemoteEvent") local player = nil local mouse = nil local connection = nil local function onActivated() --This line re:FireServer(mouse.Target) end local function onEquipped() player = game.Players.LocalPlayer mouse = player:GetMouse() connection = gun.Activated:Connect(onActivated) -- This line end local function onUnequipped() player = nil mouse = nil connection:Disconnect() end gun.Equipped:Connect(onEquipped) --These lines gun.Unequipped:Connect(onUnequipped) --These lines
wouldn’t it be better to do something like this? instead of a callback?
gun.Equipped:Connect(function() rjkiaebf wekfawiuefbiu end)
I’ve also seen remote functions written this way, and specifically remember from a DevKing video he said it should be like this.
remote.OnServerInvoke = function() aefa EfRGFO end)