Here is the Projectile script

local player = game.Players.LocalPlayer local mouse = player:GetMouse() local replicatedstorage = game:GetService("ReplicatedStorage") local ShootEvent = replicatedstorage:WaitForChild("Shoot") mouse.Button1Down:Connect(function() if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then local origin = player.Character.HumanoidRootPart.Position local direction = (Mouse.Hit.P - origin).unit ShootEvent:FireServer(origin, direction) end end
If you were in ROBLOX Studio, then you would put this in either "StarterPlayerScripts" or "StarterCharacterScripts".
Here is the ServerScript, you would put this in "ServerScriptService"!
--Whole Script local function shoot(player, origin, direction) -- Create a new part as the projectile local projectile = Instance.new("Part") projectile.Size = Vector3.new(1, 1, 1) -- Adjust the size as needed projectile.Position = origin -- Set the initial position projectile.Anchored = false -- Allow it to move projectile.CanCollide = false -- Prevent it from colliding with other objects projectile.BrickColor = BrickColor.new("Bright red") projectile.Material = Enum.Material.Neon projectile.Parent = workspace -- Add it to the workspace -- Set the velocity of the projectile local bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.Velocity = direction * 100 -- Adjust speed as needed bodyVelocity.MaxForce = Vector3.new(4000, 4000, 4000) -- Ensure it moves bodyVelocity.Parent = projectile -- Connect a Touched event to handle damage projectile.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid and hit.Parent ~= player.Character then humanoid:TakeDamage(10) -- Adjust damage as needed projectile:Destroy() -- Destroy the projectile on hit end end) -- Cleanup the projectile after 5 seconds if it doesn't hit anything game.Debris:AddItem(projectile, 5) end -- Connect the remote event to the shoot function shootEvent.OnServerEvent:Connect(shoot)