I have a game that has a kombat system, I need a player to be able to get coins for killing another player, I have reviewed a bunch of videos but they didn’t help me, I have a ready made leaderstats
Can we have the script where your weapons or things like that deal damage?
Shall I show you the whole script or the part where the player takes damage?
Whole script and the section that deals damage separately preferably.
1 Like
He’s big
game.ReplicatedStorage.MainEvent.OnServerEvent:Connect(function(plr, Argument)
if plr.Character:FindFirstChild("Stuned") then
return
end
if Argument == "Regular" then
spawn(function()
plr.Character.Humanoid.WalkSpeed = 7
task.wait(.65)
plr.Character.Humanoid.WalkSpeed = 16
end)
task.wait(.25)
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Size = Vector3.new(7,7,7)
hitbox.BrickColor = BrickColor.new("Really red")
hitbox.Transparency = 1
hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
game.Debris:AddItem(hitbox, 1)
local hitboxcooldown = false
local BV2 = Instance.new("BodyVelocity")
BV2.MaxForce, BV2.Velocity = Vector3.new(5e4, 5e2, 5e4), plr.Character.HumanoidRootPart.CFrame.lookVector * 10
BV2.Parent = plr.Character.HumanoidRootPart
game.Debris:AddItem(BV2, 0.16)
hitbox.Touched:Connect(function(hit)
if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") then
if hitboxcooldown == true then return end
hitboxcooldown = true
local vfx = game.ReplicatedStorage.VFX.Attachment:Clone()
vfx.Parent = hit.Parent.HumanoidRootPart
local sound = script.Hit:Clone()
sound.Parent = hit.Parent.HumanoidRootPart
sound:Play()
game.Debris:AddItem(sound, 2)
local BV = Instance.new("BodyVelocity")
BV.MaxForce, BV.Velocity = Vector3.new(5e4, 5e2, 5e4), plr.Character.HumanoidRootPart.CFrame.lookVector * 10
BV.Parent = hit.Parent.HumanoidRootPart
game.Debris:AddItem(BV, 0.16)
local bool = Instance.new("BoolValue")
bool.Name = "Stuned"
bool.Parent = hit.Parent.HumanoidRootPart
game.Debris:AddItem(bool, 1)
local hitAnim = hit.Parent.Humanoid:LoadAnimation(script.HitAnim)
hitAnim:Play()
game.Debris:AddItem(hitAnim, 0.6)
spawn(function()
for i, v in vfx:GetChildren() do
if v:IsA("ParticleEmitter") then
v:Emit(v:GetAttribute("EmitCount"))
end
end
end)
game.Debris:AddItem(vfx, 1.5)
hit.Parent:WaitForChild("Humanoid"):TakeDamage(math.random(3, 7))
task.wait(1)
hitboxcooldown = false
end
end)
elseif Argument == "Last" then
spawn(function()
plr.Character.Humanoid.WalkSpeed = 7
task.wait(.65)
plr.Character.Humanoid.WalkSpeed = 16
end)
task.wait(.25)
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Size = Vector3.new(7,7,7)
hitbox.BrickColor = BrickColor.new("Really red")
hitbox.Transparency = 1
hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
game.Debris:AddItem(hitbox, 1)
local hitboxcooldown = false
local BV2 = Instance.new("BodyVelocity")
BV2.MaxForce, BV2.Velocity = Vector3.new(5e4, 5e2, 5e4), plr.Character.HumanoidRootPart.CFrame.lookVector * 10
BV2.Parent = plr.Character.HumanoidRootPart
game.Debris:AddItem(BV2, 0.25)
hitbox.Touched:Connect(function(hit)
if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") then
if hitboxcooldown == true then return end
hitboxcooldown = true
local vfx = game.ReplicatedStorage.VFX.Attachment:Clone()
vfx.Parent = hit.Parent.HumanoidRootPart
local sound = script.Hit:Clone()
sound.Parent = hit.Parent.HumanoidRootPart
sound:Play()
game.Debris:AddItem(sound, 2)
local BV = Instance.new("BodyVelocity")
BV.MaxForce, BV.Velocity = Vector3.new(5e4, 5e2, 5e4), plr.Character.HumanoidRootPart.CFrame.lookVector * 90
BV.Parent = hit.Parent.HumanoidRootPart
game.Debris:AddItem(BV, 0.25)
local bool = Instance.new("BoolValue")
bool.Name = "Stuned"
bool.Parent = hit.Parent.HumanoidRootPart
game.Debris:AddItem(bool, 1)
local lastHitAnim = hit.Parent.Humanoid:LoadAnimation(script.LastHitAnim)
lastHitAnim:Play()
game.Debris:AddItem(lastHitAnim, 1)
spawn(function()
for i, v in vfx:GetChildren() do
if v:IsA("ParticleEmitter") then
v:Emit(v:GetAttribute("EmitCount"))
end
end
end)
game.Debris:AddItem(vfx, 1.5)
hit.Parent:WaitForChild("Humanoid"):TakeDamage(math.random(15, 18))
task.wait(1)
hitboxcooldown = false
end
end)
end
end)
hit.Parent:WaitForChild(“Humanoid”):TakeDamage(30)
After applying damage you can check if the Humanoid
’s health is below zero, and if it is - add coins
- Add a check to see if
hit.Parent.Humanoid.Health
is<= 0
. - If it is, then add money to the user.