Is there a error in this script?

So I have made a script tutorial and I want to make sure that there’s nothing wrong about it, but I need someone to check it because this script is for premium players(Overhead UI and Chat Name), and I don’t have premium, So I think I asked the devforum, so any thing wrong here?

Code:

-- Services
local serverScriptService = game:GetService("ServerScriptService")
local chatService = require(serverScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if player.MembershipType == Enum.MembershipType.Premium then
			local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")

			local clonedgui = billboardgui:Clone()
			clonedgui.Parent = char:FindFirstChild("Head")
			clonedgui.ImageLabel.Image = "rbxassetid://6377803675"
			clonedgui.TextLabel.Text = "Premium"
			clonedgui.TextLabel.TextColor = Color3.fromRGB(192,192,192)

			local premium = clonedgui

			chatService.SpeakerAdded:Connect(function(PlrName)
				local speaker = chatService:GetSpeaker(PlrName)
				for _, v in pairs(premium) do
					if players[PlrName].Name == v then
						speaker:SetExtraData('Tags',{{TagText = 'Premium', TagColor = Color3.fromRGB(255,255,255)}})
					end
				end
			end)
		end
	end)
end)

Thanks :slight_smile:

If you want to test it yourself, just add a not right between the if and player.MembershipType. It will check to see if you don’t have premium. Simply revert it back when finished.

3 Likes

You can do what @xMagmaDev said, or if you’re too lazy I could go in your game and test it

2 Likes

One thing I would say is that if possible, I’d move the chatservice connection outside the characteradded connection - while it’s inside, every time the character is loaded the connection is made again, which will take up more memory in the server and could cause lag eventually. Other than that, you can do what @xMagmaDev said to test, maybe instead of doing not premium say if premium or player.UserId == [yourid] to test it

2 Likes

I tried but no errors and the picture and text cant be seen :frowning:


also tried what @xMagmaDev told me, and I think the this code is wrong

clonedgui.ImageLabel.Image = "rbxassetid://6377803675"

because i think script reads it as a text, so is that code wrong?
note: also i cant use [ ] in the

if player.UserId == [yourid]

It makes it red on the first [

Hey there! It seems your output window is closed.

Go to the View tab on the top, and enable the option called output, we’ll then be able to see the errors and other print statements.

Hello! There are no errors in output and print statements weren’t put in the script, but chat wont load and the expected result wont come up

replace [yourid] with your user id, e.g. if player.UserId == 1234567
Hope this helps!

1 Like

I believe your loop is messed up, the variable premium is not a table, how then are you using it in a for loop?

1 Like

I’ve experienced the chat issue as well. You have to go into game and the explorer and the proceed to copy the “Bubble chat” and another local script named “chat script”. Now leave the game and past the scripts, proceed to drag them into starter player scripts and try again.

In your script, add a print after ever line in your main execution and see where it stops.

1 Like

Thanks for the help on the chat error! Now I only have to fix the script because It wont show the GUI that shows on Premium players

and it should look like this over the head

No worries! This is an issue with roblox not being able to replicate chat scripts into player scripts.

Please use the prints and show where it’ll stop printing in output.

1 Like

Hey there!
I tried fixing your script, and i believe this should work.

-- Services
local ServerScriptService = game:GetService("ServerScriptService")
local chatService = game:GetService("Chat")
local players = game:GetService("Players")
local ChatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
ChatService.SpeakerAdded:Connect(function(player)
	local Speaker = ChatService:GetSpeaker(player)

	print("playeradded")
	player.CharacterAdded:wait()
		print("char added")
		print(player.MembershipType)
		if player.MembershipType ~= Enum.MembershipType.Premium then
			local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")

			local clonedgui = billboardgui:Clone()
			clonedgui.Parent = player.Character:FindFirstChild("Head")
			clonedgui.ImageLabel.Image = "rbxassetid://6377803675"
			clonedgui.TextLabel.Text = "Premium"
			--clonedgui.TextLabel.TextColor = Color3.fromRGB(192,192,192)
            
			local premium = clonedgui

			
			Speaker:SetExtraData('Tags',{{TagText = 'Premium', TagColor = Color3.fromRGB(255,255,255)}})
					
		end
end)