I don't understand the problem with the script that gives kill points

I’m currently creating a kill point system using CREATOR VALUE, and I’m trying to write a script that can’t run if the value of CREATOR VALUE and its own name are the same, but I don’t know. I run it no matter if it’s the same or different value as the Creator Value
What should I do?



game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
	Character.Humanoid.Died:Connect(function()
		local Player = Character.Humanoid.creator.Value --This is the player who will give a points.
		local Leaderstats = Player.leaderstats
	print(Player)
		if Character.Humanoid:FindFirstChild('creator') and Player ~= Character.Name  then
				print(Player, Character.Name)
			Leaderstats.KILL.Value += 1
		end
	end)
end)
end)

is Character.Humanoid.creator.Value an ObjectValue or a StringValue?
If it’s an ObjectValue that holds a Player Instance then you would need to check Player.Name ~= Character.Name

1 Like

You are checking if a player instance isnt equal to a string (which is always gonna return to true)

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(Character)
        Character.Humanoid.Died:Once(function()
            local CreatorTag = Character.Humanoid:FindFirstChild('creator')
            if CreatorTag then
                local Player = CreatorTag.Value 
                local Leaderstats = Player.leaderstats
                if Player ~= Players:GetPlayerFromCharacter(Character) then
                    Leaderstats.KILL.Value += 1
                end
            end
        end)
    end)
end)

alternatively, you could also do if Player.Name ~= Character.Name then

I think this line is the problem:

You probably meant to write ‘player’ instead of ‘Player’, since ‘Player’ is a value. Leaderstats is always parented to the actual player instance, so ‘player’ in this case.

1 Like

Ah, good eye! Although i dont think he wants to reward the player who got killed, he probably meant to do this

local Leaderstats = Players[Player.Name].leaderstats

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.