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)

image

Thank you in advance.

1 Like

please help me, I want to complete the update in the next 4 hours.

where is the script located

my bad, i forgot to ask you if its a local script or server

this is a script in the player, it is server

you dont show what is in the humanoid and if the value has any children…


but im guessing you shouldve done val.Value:FindFirstChild("leaderstats") instead of val:FindFirstChild("leaderstats")

also you didnt show any errors, if there are no errors then that means Val is nil to begin with

Val = the nickname of the player is the one who killed the money and the money is credited, what is related to the color and text does not work.

I found a mistake

ah never mind sorry wait

… … …

ok so remove the Val:Connect(function(char) part

and change char to Val.Character
for example

change local head = char.Head to local head = Val.Character.Head

1 Like

image
It really works, thanks to my American colleague. :+1:t2:

1 Like

Do the other players see the name tag?

Yes, it works, I tested it with a two-player test.

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