Hello! Below I have my kill script, where Points/EXP is awarded to the player who defeats the other player. What I'd like to do is increase the value of the Points/EXP awarded, by the defeated opponents "Level" on their leaderstats.
example - if player defeats a Level 1 opponent they receive 5 points, if player defeats a Level 2 opponent, they receive 10 points, etc.
Hitting a bit of a wall on that one I've tried adding several different lines, that all seem to result in "is not a valid" with humanoid and the like. Any help suggested would be appreciated. :) Thank you!
The script below works fine, when I add the extra math for the opponent's Level, it goes bad.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) local hum = char:WaitForChild('Humanoid') hum.Died:connect(function() local tag = hum:FindFirstChild('creator') if tag ~= nil then if tag.Value ~= nil then local leaderstats = tag.Value:FindFirstChild('leaderstats') if leaderstats ~= nil then leaderstats.Points.Value = leaderstats.Points.Value + 5 leaderstats.EXP.Value = leaderstats.EXP.Value + 35 end end end end) end) end)
Create a new variable for math. Try using this. It will be based off the players EXP.
For example;
Player 1>EXP 25> Receives 42 Points.
Player 2>EXP 100> Receives 167 Points.
Player 3>EXP 350> Receives 583 Points.
Player 4>EXP 800> Receives 1,333 Points.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) local hum = char:WaitForChild('Humanoid') hum.Died:connect(function() local tag = hum:FindFirstChild('creator') if tag ~= nil then if tag.Value ~= nil then local leaderstats = tag.Value:FindFirstChild('leaderstats') if leaderstats ~= nil then local points = 5 -- How many raw points the kill is worth. local rank = leaderstats.EXP.Value / 3 -- You can adjust this value to change how dramatic the bonus is. leaderstats.Points.Value = leaderstats.Points.Value + rank * points -- Applying the math. leaderstats.EXP.Value = leaderstats.EXP.Value + 35 end end end end) end) end)