Local Script:
function onshoot()
if game.ReplicatedStorage.GunSwapBool.Value == true and game.ReplicatedStorage.PistolEquipped.Value == true and not reloading and not notshooting then
print("shooting")
shooting = true
pistolammo.Value = pistolammo.Value -1
workspace.pistolfire:Play()
track:Play()
muzzleflash.FlashGui.Flash.Visible = true
workspace.Camera.CFrame = workspace.Camera.CFrame * CFrame.Angles(math.rad(0.5),0,0)
local gunray = Ray.new(muzzleflash.Position, (mouse.Hit.p - muzzleflash.Position).unit * 990)
local part, pos = workspace:FindPartOnRayWithIgnoreList(gunray, {workspace.CurrentCamera, game.Players.LocalPlayer.Character})
if part then
game.ReplicatedStorage.RemoteEventPistol:FireServer(part, pos)
end
end
end
mouse.Button1Down:Connect(function()
onshoot()
end)
Script:
pistolevent.OnServerEvent:Connect(function(plr, part, pos)
if part.Parent:FindFirstChild("Humanoid") then
local humanoid = part.Parent.Humanoid
if humanoid.Health > 0 and part.Name == "Head" then
humanoid:TakeDamage(90)
wait(0.1)
print("Edamage")
humanoid:TakeDamage(100)
elseif humanoid.Health > 0 and part.Name ~= "Head" then
humanoid:TakeDamage(30)
print("Edamage")
end
else
local bullet = Instance.new("Part")
bullet.BrickColor = BrickColor.new("Black")
bullet.Size = Vector3.new(0.1,0.1,0.1)
bullet.Position = pos
bullet.Anchored = true
bullet.CanCollide = false
bullet.Parent = workspace.bullets
debris:AddItem(bullet, 2)
end
end)

4 comments
Can you add a print in the serverscript to test if it really works or not?
yah
ill try that
it doesn't print