I don’t know how to give a player points (leaderstats, not PointsService) when they kill another player, can someone show me how this is done?
I can provide weapon scripts if you need!
Thank you!
I don’t know how to give a player points (leaderstats, not PointsService) when they kill another player, can someone show me how this is done?
I can provide weapon scripts if you need!
Thank you!
Can you provide the weapon script?
Their at countless YouTube tutorial and devforum posts on this. Please look it up before making a post.
I’ll list what you need:
1-Add a creator tag in the humanoid when they die. (Make it reference the player that killed them)
2-When the player dies get the creator tag, get the value (that is the player that killed them) then add points to that player
Here is my weapon script:
local tool = script.Parent
local canDamage = false
local dmg = script.Parent.Damage.Value
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(dmg)
script.Parent.Sound:Play()
else
return
end
canDamage = false
end
local function slash()
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool
canDamage = true
end
tool.Activated:Connect(slash)
tool.DMG.Touched:Connect(onTouch)
Is this a localscript or a normal script? (nvm wow I see takedamage)
Normal script
This text will be blurred
You can get the tools parent which is the character and you can get their name and reference their leaderstats and change it through this script.
But how would I detect if they got a kill?
You could check the humanoid’s health and if it is <= 0 then you can give them credit for it
Hmm, ok! But can you provide the edited weapon script?
I don’t know because I can’t test but here is what I think should work:
local tool = script.Parent
local canDamage = false
local dmg = script.Parent.Damage.Value
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(dmg)
script.Parent.Sound:Play()
if humanoid.Health <= 0 then
Game.Players:WaitForChild(tool.Parent.Name).leaderstats.points += 100
end
else
return
end
canDamage = false
end
local function slash()
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool
canDamage = true
end
tool.Activated:Connect(slash)
tool.DMG.Touched:Connect(onTouch)
Alright, just let me test it real quick…
It didnt work
Can I see the game explorer of the tool and of your character in game?
I have obtained working code, I have a solution
Hi, can you share the code that you ending up using for this?
Thanks