Server Script:
local rs = game:GetService("ReplicatedStorage")
rs.Shoot.OnServerEvent:Connect(function(plr,hit,target,handle,shooter)
if target ~= nil then
handle["Gunshot"]:Play()
local hum = target.Parent:FindFirstChildWhichIsA("Humanoid")
if hum then
if target.Name == "Head" then
hum.Health = 0
else
hum.Health -= math.random(50,100)
end
end
local a = Instance.new("Attachment",target)
a.Position = Vector3.new(hit.X,hit.Y,hit.Z)
shooter["Beam"].Attachment1 = a
wait(0.1)
a:Destroy()
end
end)
Local Script (in Tool)
local mouse = game.Players.LocalPlayer:GetMouse()
local rs = game:GetService("ReplicatedStorage")
script.Parent.Activated:Connect(function()
rs.Shoot:FireServer(mouse.Hit,mouse.Target,script.Parent.Handle,script.Parent.Fire)
end)