-
What do you want to achieve?
My goal is to have the script detect whether the player that is killed is the same rank or higher, if so they get added 1 to their current rank. -
What is the issue?
When killing somebody of the same rank the rank does not advance after 2. -
What solutions have you tried so far?
I have tried different ways on getting the rank of the opponent but no matter what the script prints out that the opponent’s Rank is 1 even when it’s not.
Script:
local DebounceTable = {}
local KillDebounce = {}
local tool = script.Parent
local DeadplayerTouch = false
-- local Player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
script.Parent:WaitForChild("Hitbox").Touched:Connect(function(objectThatTouchesTheHitbox)
if objectThatTouchesTheHitbox.Parent then
if objectThatTouchesTheHitbox.Parent:FindFirstChild("Humanoid") then
if DebounceTable[objectThatTouchesTheHitbox.Parent] == true then return end
DebounceTable[objectThatTouchesTheHitbox.Parent] = true
local LocalPlayer = tool.Parent.Humanoid
objectThatTouchesTheHitbox.Parent.Humanoid:TakeDamage(10)
if objectThatTouchesTheHitbox.Parent.Humanoid.Health <= 0 then
if objectThatTouchesTheHitbox.Parent.Humanoid == LocalPlayer then return end
if DeadplayerTouch == false then
local opponent = game:GetService("Players"):GetPlayerFromCharacter(objectThatTouchesTheHitbox.Parent)
local opponentRank = opponent.leaderstats.Rank
local you = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
local youRank = you.leaderstats.Rank
if youRank.Value <= opponentRank.Value then
DeadplayerTouch = true
local NewRank = youRank.Value + 1
youRank.Value = NewRank
wait(5)
DeadplayerTouch = false
end
print("You Killed " ..objectThatTouchesTheHitbox.Parent.Name.." Rank: "..opponentRank.Value)
print("Your rank is "..youRank.Value)
end
end
wait(.5)
DebounceTable[objectThatTouchesTheHitbox.Parent] = nil
end
end
end)