Help the script is not working

I have a script that is in the player, every time he dies, he should check the number of kills of the killer and give him the appropriate inscription above the player. But something is not working. After killing, the inscription above the player does not change.
Here is my script:

local player = script.Parent
local Humanoid = player:WaitForChild("Humanoid")

function Frag()
	local Val = Humanoid:FindFirstChild("creator") and Humanoid.creator.Value
	if Val then
		local leaderstats = Val:FindFirstChild("leaderstats")
		leaderstats.Coins.Value = leaderstats.Coins.Value + 15 -- стоимость фрага
		leaderstats.Kills.Value = leaderstats.Kills.Value + 1
		
		local Players = game:GetService("Players")

		Val:Connect(function(char)
		local head = char.Head
		local lowertext = head.NameTag.LowerText
		local humanoid = char.Humanoid

		humanoid.DisplayDistanceType = "None"

		if Val.leaderstats.Kills.Value <= 1 then
			lowertext.Text = "Noob"
			lowertext.TextColor3 = Color3.fromRGB(10, 214, 255)
		end
		if Val.leaderstats.Kills.Value >= 2 then
			lowertext.Text = "Pro"
			lowertext.TextColor3 = Color3.fromRGB(10, 214, 255)
		end


		script:Remove()
		end)
	end
end

Humanoid.Died:connect(Frag)

194407e0a2e7cf17bbf673ec479f8a78f789a9b1

Thank you in advance.

1 Like

do a print if val is being read in the game.

so under if Val then add an elseif not Val then, add another print to see

print(Val)
1 Like

I found a mistake.

1 Like

And I realized what the problem is.

2 Likes

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