Script works only in studio

Hello, I have one script for titles for players, the script works in the studio, but it does not work on roblox servers and on team tests in the studio. The script was transferred from another game where it works without any problems, below I am pasting the game error and the line that causes error

local function CharacterAdded(Character)

		local Head = Character:WaitForChild("Head")

		local EstTag = nil

		for i,v in pairs(Titles) do

			if v["Kills"] == 0 then

				EstTag = i

			end

		end

		for i,v in pairs(Titles) do

			if v["Kills"] <= Kills.Value and v["Kills"] > Titles[EstTag]["Kills"] then

				EstTag = i

			end

		end

		local NewTitle = Title:Clone()

		NewTitle.Parent = Head

		NewTitle:WaitForChild("TextLabel").Text = EstTag

		NewTitle:WaitForChild("TextLabel").TextColor3 = Titles[EstTag]['Color']

		local Humanoid = Character:WaitForChild("Humanoid")

		Humanoid.Died:Connect(function()

			pcall(function()

				local Tag = Humanoid:FindFirstChild("creator")

				local Killer = Tag.Value

				if Tag and Killer then

					Killer:WaitForChild("Kills").Value += 1

				end

			end)

		end)

	end

	CharacterAdded(Player.Character)
1 Like

Have you tried using player.CharacterAdded:Connect(CharacterAdded) instead?

Yep that was the problem and the script already have this i just had to remove CharacterAdded(Player.Character)

1 Like