I have a simple raycasting gun, and on my screen it shows that I have damaged / killed an enemy, but on the other players screen nothing has happened. Here is the gun script:
--Variables local player = game.Players.LocalPlayer local mouse = player:GetMouse() local tool = script.Parent local equipped = false local UserInputService = game:GetService("UserInputService") local mouseDown = false local canPlay = true local mouse = game.Players.LocalPlayer:GetMouse() local shootSound = tool.shoot local reloadSound = tool.Reload local equipSound = tool.Equip local ammo = tool.Ammo.Value local gui = tool.ak47Gui local ammoLabel = gui.Frame.ammo local reloading = false --Gui invisible gui.Parent = nil --Setting up full auto mouse.Button1Down:Connect(function() mouseDown = true end) mouse.Button1Up:Connect(function() mouseDown = false end) --Setting up equipped / unequipped variables tool.Equipped:Connect(function(mouse) equipSound:Play() equipped = true gui.Parent = player.PlayerGui end) tool.Unequipped:Connect(function(mouse) equipped = false gui.Parent = nil end) --Key Press Functions UserInputService.InputBegan:Connect(function(input, gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard and equipped == true then --Reload Function local keyPressed = input.KeyCode if keyPressed == Enum.KeyCode.R and reloading == false then reloading = true canPlay = false print("reloading!") reloadSound:Play() wait(2.5) ammo = 30 canPlay = true reloading = false end end if input.UserInputType == Enum.UserInputType.MouseButton2 and equipped == true then --Aim Function end end) --Equipped Functions tool.Equipped:Connect(function() while true do if reloading == false then ammoLabel.Text = ammo --Updating Gui Text else ammoLabel.Text = "Reloading" --Updating Gui Text end wait() if mouseDown then --Shooting if equipped then if canPlay then if ammo >= 1 then canPlay = false local randomnum = math.random(1.5)-1 local randomvector = Vector3.new(randomnum,randomnum,randomnum) --Spread local ray = Ray.new(tool.shootPart.CFrame.p, (mouse.Hit.p + randomvector - tool.shootPart.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local beam = Instance.new("Part", workspace) --Creating Ray beam.BrickColor = BrickColor.new("Brick yellow") beam.FormFactor = "Custom" beam.Material = "Neon" beam.Transparency = 0.5 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (tool.shootPart.CFrame.p - position).magnitude beam.Size = Vector3.new(0.1, 0.1, distance) beam.CFrame = CFrame.new(tool.shootPart.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) game:GetService("Debris"):AddItem(beam, 0.1) if part then local humanoid = part.Parent:FindFirstChild("Humanoid") --Checks for person if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") --Checks for person end if humanoid then humanoid:TakeDamage(24) --Damages end end shootSound:Play() --Play sound ammo = ammo - 1 --Subtract ammo wait(0.1) --Firerate canPlay = true elseif reloading == false then --Reload Function reloadSound:Play() reloading = true wait(2.5) ammo = 30 canPlay = true reloading = false end end end end end end)
This is inside of a local script in side of the gun. Any help is appreciated :)
Local scripts editing server-side object will only show for the LocalPlayer, use a remoteevent to deal with the taking damage portion of the script(or anything you want other players to see).
https://developer.roblox.com/en-us/api-reference/class/RemoteEvent