Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

(Answered) Why am I recieving "tables cannot be cyclic?"

I am receiving a "tables cannot be cyclic" error from line #10 of the following script:

local ServerScriptService = game:GetService("ServerScriptService")
local ChatServiceRunner = ServerScriptService:WaitForChild("ChatServiceRunner")
local ChatService = require(ChatServiceRunner.ChatService)

local giveTag = game.ReplicatedStorage.GiveTag

giveTag.OnServerEvent:Connect(function(player)
	local speaker = ChatService:GetSpeaker(player.Name)
	
	local class = game.ReplicatedStorage:WaitForChild(speaker):WaitForChild("Class")
	
	local DefaultTags = {
		{TagText = class, TagColor = Color3.new(1,0,0)},
	}
	if speaker and speaker:GetPlayer() then
		speaker:SetExtraData("Tags", DefaultTags)
	end
end)

The "class value" that line #10 is looking for is a StringValue that is generated by the script below; players' "class value" exists within its own individual folder sharing the same name as its designated player.

game.Players.PlayerAdded:connect(function(player)
	local folder = Instance.new("Folder")
	folder.Parent = game.ReplicatedStorage
	folder.Name = player.Name
	local Class = Instance.new("StringValue", folder)
	Class.Name = "Class"
	Class.Value = "No class"
end)

If additional clarification is needed, please don't hesitate to tell me. All help is appreciated!

9 comments

1

Try doing "speaker.Name" or instead "player.Name"

0

Sadly I recieved "Chat.ClientChatModules.MessageCreatorModules.DefaultChatMessage:52: invalid argument #2 to 'format' (string expected, got Instance)" from using "speaker.Name" and "player.Name"

1

On line 10 it should work with player.Name, since you're using it in WaitForChild

0

Whenever I send a chat message I still recieve "Chat.ClientChatModules.MessageCreatorModules.DefaultChatMessage:52: invalid argument #2 to 'format' (string expected, got Instance)," could it be because I'm using studio instead of testing it out in a live game?

1

I actually don't know, which line in the script you included sends this error?

0

Presumably line #10, however, the error I'm receiving now comes from chat module scripts because I think it may be indentifying something incorrectly and consequencely not letting me send a message.

2

When you get the error you also get a "backtrace" so you see which line in the first script has the error. I would actually guess it's line 16 but I don't know

1

that’s strange. as far as I know, waitforchild(player.Name) is definitely a string. it sounds like you might be changing the wrong line. have you changed line 10 “speaker” to “player.Name”? he is correct that it’s probably line 16 (a new problem).

0

I found the problem, player.Name worked, the miscommunication came from line 13 which asked for "class" when it should have been asking for "class.Value." Thank you so much for your help!

1 answer

Courtesy of @Spjureeedd, all that had to be changed was "speaker" to "player.Name" in line 10 and "class" to "class.Value" in line 13!

This discussion is preserved as it was. New answers, comments, and votes are closed.