Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

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!

1
Try doing "speaker.Name" or instead "player.Name" Spjureeedd 385 — 3y
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" ChirpPerson 74 — 3y
1
On line 10 it should work with player.Name, since you're using it in WaitForChild Spjureeedd 385 — 3y
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? ChirpPerson 74 — 3y
View all comments (5 more)
1
I actually don't know, which line in the script you included sends this error? Spjureeedd 385 — 3y
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. ChirpPerson 74 — 3y
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 Spjureeedd 385 — 3y
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). Speedmask 661 — 3y
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! ChirpPerson 74 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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!

Ad

Answer this question