local Players = game:GetService("Players") local Debris = game:GetService("Debris") -- userame confimation local TARGET_USERNAME = "enter your username here" local DAMAGE = 25 local MAX_DISTANCE = 500 local COOLDOWN = 0.25 local lastShot = {} local originalShoulderC0 = {} -- 1. Raise or reset R15 Right Arm aiming pose local function setR15AimPose(character, isAiming) local rightUpperArm = character:FindFirstChild("RightUpperArm") local rightShoulder = rightUpperArm and rightUpperArm:FindFirstChild("RightShoulder") if not rightShoulder or not rightShoulder:IsA("Motor6D") then return end if isAiming then if not originalShoulderC0[character] then originalShoulderC0[character] = rightShoulder.C0 end -- Point R15 right arm straight forward rightShoulder.C0 = originalShoulderC0[character] * CFrame.Angles(math.rad(90), 0, 0) else if originalShoulderC0[character] then rightShoulder.C0 = originalShoulderC0[character] originalShoulderC0[character] = nil end end end -- 2. create the gun local function equipGun(player) local character = player.Character if not character or character:FindFirstChild("AttachedGun") then return end local humanoid = character:FindFirstChildOfClass("Humanoid") if not humanoid or humanoid.Health <= 0 then return end -- R15 specific hand check local rightHand = character:FindFirstChild("RightHand") if not rightHand then return end local gunModel = Instance.new("Model") gunModel.Name = "AttachedGun" gunModel.Parent = character -- Grip local grip = Instance.new("Part") grip.Name = "Grip" grip.Size = Vector3.new(0.32, 0.95, 0.42) grip.Color = Color3.fromRGB(30, 30, 30) grip.Material = Enum.Material.SmoothPlastic grip.CanCollide = false grip.Massless = true grip.Parent = gunModel -- Barrel local barrel = Instance.new("Part") barrel.Name = "Barrel" barrel.Size = Vector3.new(0.28, 0.28, 1.65) barrel.Color = Color3.fromRGB(80, 80, 80) barrel.Material = Enum.Material.Metal barrel.CanCollide = false barrel.Massless = true barrel.Parent = gunModel -- Muzzle Attachment local muzzle = Instance.new("Attachment") muzzle.Name = "Muzzle" muzzle.Position = Vector3.new(0, 0, -0.825) muzzle.Parent = barrel -- Align Grip to R15 RightGripAttachment for accurate palm placement local gripAttachment = rightHand:FindFirstChild("RightGripAttachment") if gripAttachment then grip.CFrame = gripAttachment.WorldCFrame * CFrame.new(0, -0.15, 0) else grip.CFrame = rightHand.CFrame * CFrame.new(0, -0.15, -0.1) end local w1 = Instance.new("WeldConstraint") w1.Part0 = rightHand w1.Part1 = grip w1.Parent = grip -- Weld Barrel onto top of the Grip barrel.CFrame = grip.CFrame * CFrame.new(0, 0.38, -0.6) local w2 = Instance.new("WeldConstraint") w2.Part0 = grip w2.Part1 = barrel w2.Parent = barrel -- Raise R15 arm so the gun points forward setR15AimPose(character, true) -- Server-side click trigger (invisible, no handle) local trigger = Instance.new("Tool") trigger.Name = "FireTrigger" trigger.RequiresHandle = false trigger.CanBeDropped = false trigger.Parent = character trigger.Activated:Connect(function() local now = tick() if lastShot[player] and (now - lastShot[player] < COOLDOWN) then return end lastShot[player] = now local root = character:FindFirstChild("HumanoidRootPart") if not root or not muzzle.Parent then return end local startPos = muzzle.WorldPosition local direction = root.CFrame.LookVector * MAX_DISTANCE local params = RaycastParams.new() params.FilterDescendantsInstances = {character} params.FilterType = Enum.RaycastFilterType.Exclude local result = workspace:Raycast(startPos, direction, params) local endPos = result and result.Position or (startPos + direction) -- Server-side Neon Bullet Tracer (Visible to everyone) local dist = (endPos - startPos).Magnitude local tracer = Instance.new("Part") tracer.Anchored = true tracer.CanCollide = false tracer.Material = Enum.Material.Neon tracer.Color = Color3.fromRGB(255, 200, 0) tracer.Size = Vector3.new(0.14, 0.14, dist) tracer.CFrame = CFrame.lookAt(startPos, endPos) * CFrame.new(0, 0, -dist / 2) tracer.Parent = workspace Debris:AddItem(tracer, 0.1) -- Deal Damage on Server if result and result.Instance then local hitModel = result.Instance:FindFirstAncestorOfClass("Model") local hitHum = hitModel and hitModel:FindFirstChildOfClass("Humanoid") if hitHum and hitHum.Health > 0 then hitHum:TakeDamage(DAMAGE) end end end) end -- 3. unequip the gun local function unequipGun(player) local character = player.Character if not character then return end setR15AimPose(character, false) local gun = character:FindFirstChild("AttachedGun") if gun then gun:Destroy() end local trigger = character:FindFirstChild("FireTrigger") if trigger then trigger:Destroy() end local backpack = player:FindFirstChild("Backpack") if backpack then local bpTrigger = backpack:FindFirstChild("FireTrigger") if bpTrigger then bpTrigger:Destroy() end end end -- 4. Listen for /e and /q local function setupPlayer(player) if player.Name ~= TARGET_USERNAME then return end player.CharacterRemoving:Connect(function(character) originalShoulderC0[character] = nil end) player.Chatted:Connect(function(msg) local cleanMsg = string.lower(msg) if cleanMsg == "/e" or cleanMsg == "e" then equipGun(player) elseif cleanMsg == "/q" or cleanMsg == "q" then unequipGun(player) end end) end Players.PlayerAdded:Connect(setupPlayer) for _, p in ipairs(Players:GetPlayers()) do setupPlayer(p) end Players.PlayerRemoving:Connect(function(player) lastShot[player] = nil end)