-- LocalScript in StarterPlayerScripts local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local StarterGui = game:GetService("StarterGui") local player = Players.LocalPlayer local isHoldingMouse = false local autoFireEnabled = false -- starts OFF local currentTool = nil local currentRemote = nil local character = nil -- we'll set this properly -- ─── Function to set up everything for a new character ─────────────────────── local function setupCharacter(newChar) character = newChar currentTool = nil currentRemote = nil -- Re-check tool immediately (in case already equipped on spawn) task.spawn(function() task.wait(0.15) -- tiny delay helps replication updateTool() end) end -- ─── Tool change detection ─────────────────────────────────────────────────── function updateTool() currentTool = nil currentRemote = nil if not character or not character.Parent then return end local tool = character:FindFirstChildWhichIsA("Tool") if not tool then return end currentTool = tool -- Common combat/anime game structure local rctFolder = tool:FindFirstChild(tool.Name) or character:FindFirstChild(tool.Name) if not rctFolder then return end local localFolder = rctFolder:FindFirstChild("Local") if not localFolder then return end local eventSkill = localFolder:FindFirstChild("EventSkill") if eventSkill and eventSkill:IsA("RemoteEvent") then currentRemote = eventSkill -- print("Auto-fire ready for:", tool.Name) end end -- ─── Input handling ────────────────────────────────────────────────────────── UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.UserInputType == Enum.UserInputType.MouseButton1 then isHoldingMouse = true end if input.KeyCode == Enum.KeyCode.U then autoFireEnabled = not autoFireEnabled pcall(function() StarterGui:SetCore("SendNotification", { Title = "Auto Fire", Text = autoFireEnabled and "ENABLED (press U)" or "DISABLED (press U)", Duration = 2.8 }) end) end end) UserInputService.InputEnded:Connect(function(input, gameProcessed) if gameProcessed then return end if input.UserInputType == Enum.UserInputType.MouseButton1 then isHoldingMouse = false end end) -- ─── Character / tool events ───────────────────────────────────────────────── local function onCharacterAdded(newChar) setupCharacter(newChar) -- Connect tool listeners **on the new character** newChar.ChildAdded:Connect(function(child) if child:IsA("Tool") then task.delay(0.08, updateTool) -- small delay = more reliable end end) newChar.ChildRemoved:Connect(function(child) if child:IsA("Tool") then currentTool = nil currentRemote = nil end end) end -- Initial character + future respawns if player.Character then onCharacterAdded(player.Character) end player.CharacterAdded:Connect(onCharacterAdded) -- ─── Main fast loop ────────────────────────────────────────────────────────── RunService.Heartbeat:Connect(function(dt) if not autoFireEnabled then return end if not isHoldingMouse then return end if not currentRemote then return end -- Fires every frame (~60 Hz) — server usually rate-limits -- For ~5/sec instead, uncomment: -- if dt < 0.19 then return end currentRemote:FireServer() end)