local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')
local Particle = game.ReplicatedStorage.ParticleEmitter
local hit = ReplicatedStorage.Hit
local damage_amount = 14
remoteEvent.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)
local leadestats = player.leaderstats
local goldStats = leadestats and leadestats:FindFirstChild("Gold")
local bullet = Instance.new("Part")
bullet.Name = 'Bullet'
bullet.Parent = game.Workspace.Bullets
bullet.Size = Vector3.new(0.25, 0.25, 0.25)
bullet.BrickColor = BrickColor.new('White')
bullet.Shape = Enum.PartType.Ball
local speed = 250
bullet.CFrame = CFrame.new(gunPos, mosPos)
bullet.Velocity = bullet.CFrame.lookVector * speed
local particle = Particle:Clone()
bullet.Touched:Connect(function(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
if humanoid and humanoid.Parent.Name ~= player.Name then
if humanoid.Health > 0 and humanoid.Health - damage_amount <= 0 then
end
humanoid:TakeDamage(damage_amount)
if goldStats then
goldStats.Value += 20
hit:Play()
if humanoid.Health <=0 then
player.PlayerGui.KillGui.Enabled = true
player.PlayerGui.KillGui.TextLabel.Text = "Killed: " .. otherPart.Parent.Name
wait(3)
player.PlayerGui.KillGui.Enabled = false
Particle.Parent = otherPart:FindFirstChild("Head")
Particle.Enabled = true
game:GetService('Debris'):AddItem(Particle, 1) --adjust time before particle gets destroyed
end
bullet:Destroy()
end
end
game:GetService('Debris'):AddItem(bullet, 1)
end)
end)
and theres a line
humanoid:TakeDamage(damage_amount)
if goldStats then
goldStats.Value += 20
but what i’ve noticed is that after the player’s dead you can still shoot them and have even more money. How would i fix that?
if humanoid.Health > 0 and humanoid.Health - damage_amount <= 0 and goldStats then
end
if goldStats then
goldStats.Value += 20
humanoid:TakeDamage(damage_amount)
No. The placement end statement you have there creates an empty if statement, meaning nothing changes regardless of whether the condition is met.
Something like this would be best.
if humanoid.Health > 0 then
if humanoid.Health - damage_amount <= 0 and goldStats then
goldStats.Value += 20
end
humanoid:TakeDamage(damage_amount)
end