What is wrong with my gui script

title, basically im trynna make a script where i connect the group to my game, and based on your rank in my group, you get an overhead tag. This script is inside a screengui in ReplicatedStorage.
script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local overheadGui = script.NameTag
local groupId = 17172847

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()

		local Success,Result = pcall(function()
			return player:GetRankInGroup(groupId)
		end)

		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"

		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = player.Name

		if Success then -- here
			if Result >= 254 then
				overheadGuiClone.PlayerRank.Text = "Goofiest Of All Goobers"
				spawn(function()
					while task.wait() do
						local t = 5; 
						local hue = tick() % t / t
						local colorrr = Color3.fromHSV(hue, 1, 1)
						overheadGuiClone.PlayerRank.TextColor3 = colorrr
					end -- to here is making a rainbow color
				end)
			elseif Result == 253 then
				overheadGuiClone.PlayerRank.Text = "Ultra Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
			elseif Result == 2 then
				overheadGuiClone.PlayerRank.Text = "Mega Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
			elseif Result == 1 then
				overheadGuiClone.PlayerRank.Text = "Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
			elseif Result == 0 then
				overheadGuiClone.PlayerRank.Text = ""
			end
		end
	end)
end)

PLEASE HELP

3 Likes

Why are you doing it based of every time the player chats?

3 Likes

Try printing Result and tell me what it says. I have an idea why it might not be working, but I want to see if I rule that out first

3 Likes

Nothing appeared in OutPut, but I got this error in it though: Infinite yield possible on 'ServerScriptService:WaitForChild("ChatServiceRunner")

Well, did you make sure everything is spelled right and that it exists in ServerScriptService before running the game?

1 Like

ok, i just did my research and i found out that they replaced ChatServiceRunner with Chat.
But I did that, and nothing happened.

1 Like

you have parented the script to Replicated Storage which is stopping to from running, try parenting it to Starter Player Scripts.

1 Like

did that, and got the error NameTag is not a valid member of LocalScript "Players.GammerAtomYT.PlayerScripts.overheadGui.LocalScript"

also heres what the script looks like so far:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = game:GetService("Chat")
local overheadGui = script.NameTag
local groupId = 17172847

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()

		local Success,Result = pcall(function()
			return player:GetRankInGroup(groupId)
		end)

		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"

		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = tostring(player.Name)

		if Success then -- here
			if Result >= 254 then
				overheadGuiClone.PlayerRank.Text = "Goofiest Of All Goobers"
				spawn(function()
					while task.wait() do
						local t = 5; 
						local hue = tick() % t / t
						local colorrr = Color3.fromHSV(hue, 1, 1)
						overheadGuiClone.PlayerRank.TextColor3 = colorrr
					end -- to here is making a rainbow color
				end)
			elseif Result == 253 then
				overheadGuiClone.PlayerRank.Text = "Ultra Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
			elseif Result == 2 then
				overheadGuiClone.PlayerRank.Text = "Mega Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
			elseif Result == 1 then
				overheadGuiClone.PlayerRank.Text = "Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
			elseif Result == 0 then
				overheadGuiClone.PlayerRank.Text = ""
				print(Result)
			end
		end
	end)
end)

can you send a screen short of explorer where name tag is parented to.

2 Likes

try this script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = game:GetService("Chat")
local overheadGui = game.Players.LocalPlayer:WaitForChild("overheadGui")
local groupId = 17172847

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()

		local Success,Result = pcall(function()
			return player:GetRankInGroup(groupId)
		end)

		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"

		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = tostring(player.Name)

		if Success then -- here
			if Result >= 254 then
				overheadGuiClone.PlayerRank.Text = "Goofiest Of All Goobers"
				spawn(function()
					while task.wait() do
						local t = 5; 
						local hue = tick() % t / t
						local colorrr = Color3.fromHSV(hue, 1, 1)
						overheadGuiClone.PlayerRank.TextColor3 = colorrr
					end -- to here is making a rainbow color
				end)
			elseif Result == 253 then
				overheadGuiClone.PlayerRank.Text = "Ultra Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
			elseif Result == 2 then
				overheadGuiClone.PlayerRank.Text = "Mega Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
			elseif Result == 1 then
				overheadGuiClone.PlayerRank.Text = "Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
			elseif Result == 0 then
				overheadGuiClone.PlayerRank.Text = ""
				print(Result)
			end
		end
	end)
end)

tried that, still didn’t work for some reason.

got an infinite yield error, where you tried to define overheadGui

place the overheadGui in StarterGui and try this

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = game:GetService("Chat")
local overheadGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("overheadGui")
local groupId = 17172847

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()

		local Success,Result = pcall(function()
			return player:GetRankInGroup(groupId)
		end)

		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"

		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = tostring(player.Name)

		if Success then -- here
			if Result >= 254 then
				overheadGuiClone.PlayerRank.Text = "Goofiest Of All Goobers"
				spawn(function()
					while task.wait() do
						local t = 5; 
						local hue = tick() % t / t
						local colorrr = Color3.fromHSV(hue, 1, 1)
						overheadGuiClone.PlayerRank.TextColor3 = colorrr
					end -- to here is making a rainbow color
				end)
			elseif Result == 253 then
				overheadGuiClone.PlayerRank.Text = "Ultra Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
			elseif Result == 2 then
				overheadGuiClone.PlayerRank.Text = "Mega Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
			elseif Result == 1 then
				overheadGuiClone.PlayerRank.Text = "Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
			elseif Result == 0 then
				overheadGuiClone.PlayerRank.Text = ""
				print(Result)
			end
		end
	end)
end)
1 Like

tried that, still didn’t work?
(character limit)

any errors ?

1 Like

no, no errors in output.

(IHATE CHARACTER LIMIT)

did I print Result ?

1 Like

yes i put print(Result) in the script, and yet nothing appeared in output.

script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = game:GetService("Chat")
local overheadGui = game:GetService("StarterGui"):WaitForChild("overheadGui")
local groupId = 17172847

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()

		local Success,Result = pcall(function()
			return player:GetRankInGroup(groupId)
		end)

		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"

		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = tostring(player.Name)

		if Success then -- here
			if Result >= 254 then
				overheadGuiClone.PlayerRank.Text = "Goofiest Of All Goobers"
				spawn(function()
					while task.wait() do
						local t = 5; 
						local hue = tick() % t / t
						local colorrr = Color3.fromHSV(hue, 1, 1)
						overheadGuiClone.PlayerRank.TextColor3 = colorrr
					end -- to here is making a rainbow color
				end)
			elseif Result == 253 then
				overheadGuiClone.PlayerRank.Text = "Ultra Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
			elseif Result == 2 then
				overheadGuiClone.PlayerRank.Text = "Mega Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
			elseif Result == 1 then
				overheadGuiClone.PlayerRank.Text = "Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
			elseif Result == 0 then
				overheadGuiClone.PlayerRank.Text = ""
				print(Result)
			end
		end
	end)
end)

You have put the print in wrong line, try this and lmk what did it print

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = game:GetService("Chat")
local overheadGui = script.NameTag
local groupId = 17172847

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()

		local Success,Result = pcall(function()
			return player:GetRankInGroup(groupId)
		end)

		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"

		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = tostring(player.Name)
		if Success then -- here
				print(Result)
			if Result >= 254 then
				overheadGuiClone.PlayerRank.Text = "Goofiest Of All Goobers"
				spawn(function()
					while task.wait() do
						local t = 5; 
						local hue = tick() % t / t
						local colorrr = Color3.fromHSV(hue, 1, 1)
						overheadGuiClone.PlayerRank.TextColor3 = colorrr
					end -- to here is making a rainbow color
				end)
			elseif Result == 253 then
				overheadGuiClone.PlayerRank.Text = "Ultra Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
			elseif Result == 2 then
				overheadGuiClone.PlayerRank.Text = "Mega Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
			elseif Result == 1 then
				overheadGuiClone.PlayerRank.Text = "Goober"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
			elseif Result == 0 then
				overheadGuiClone.PlayerRank.Text = ""
			end
		end
	end)
end)

The game wouldn’t load cause of this error:

NameTag is not a valid member of LocalScript "Players.GammerAtomYT.PlayerGui.overheadGui.LocalScript"