Today I’ve finished a good part of my weapon finished. This includes melee, firing etc. But we have noticed the past few days that when yo kill someone with the bullet or the bayonet it doesn’t add a kill to the leaderboard.
Is there anyway to make the tool register the kill.
I’m not supposed to write the code for you but here the code.
local p = game.Players.LocalPlayer
local m = p:GetMouse()
script.Parent.Activated:Connect(function()
local part = Instance.new("Part")
part.Parent = workspace
part.Position = m.Hit.p
part.Touched:Connect(function(Hu)
if Hu.Parent:FindFirstChild"Humanoid" then
if Hu.Parent.Humanoid.Health == 0 then
else
script.Parent.Shot:FireServer(part , Hu)
end
end
part:Destroy()
end)
end)
That is local script
Above is local script and under is script.
script.Parent.Shot.OnServerEvent:Connect(function(pl , Part , Hu)
if Hu.Parent:FindFirstChild("Humanoid") then
Hu.Parent.Humanoid:TakeDamage(10)
if Hu.Parent.Humanoid.Health <= 0 then
local leaderstats = pl:FindFirstChild("leaderstats")
local Kills = leaderstats:FindFirstChild("Kills")
Kills.Value = Kills.Value + 1
end
end
end)
that is the script. You can mess up with the code on your style.
What this code block does is that it if Kills.Value is anything but 0 then it does not run further. That is why your Kills.Value does not increase (after the first kill). Is this supposed to be intended behaviour?