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

Attempt Concatenate local DivisionTable?

Asked by 5 years ago
Edited 5 years ago

I have a problem in my script, but before we get to it this is my script






--Locals game.ReplicatedStorage.RemoteEvents.GUIRemote.OnServerEvent:Connect(function() local players = game.Players.LocalPlayer local Billboard = game.ReplicatedStorage.BillboardGui local Rank = players:GetRoleInGroup(889994) local Division = players:GetRoleInGroup(889994) -- Not yet decided local Division2 = players:GetRoleInGroup(797574) local Division3 = players:GetRoleInGroup(889994) -- Not yet decided local Division4 = players:GetRoleInGroup(889994) -- Not yet decided local DivisionTable = {Division,Division2,Division3,Division4} print("Hi") --GUI players.TeamColor = BrickColor.new("Really black") players:LoadCharacter() local Clone = Billboard:Clone() Clone.TextLabel.Text = ("Rank:"..Rank) Clone.Parent = game.Workspace:FindFirstChild(players.Name).Head --A pairs loop to check for Geust for i,v in pairs (DivisionTable)do print("Hi") if v == "Geust" then table.remove(DivisionTable,v) else end end --Now that we have removed the incompatible ones, we will put the billboard above 2 local Clone2 = Billboard:Clone() Clone2.StudsOffset = (Vector3.new(0,2.5,0)) Clone2.TextLabel.Text = ("Division:"..DivisionTable) Clone2.Parent = game.Workspace:FindFirstChild(players.Name).Head end)

The error responds with

17:20:27.030 - ServerScriptService.Script:37: attempt to concatenate local 'DivisionTable' (a table value) 17:20:27.030 - Stack Begin 17:20:27.030 - Script 'ServerScriptService.Script', Line 37 17:20:27.031 - Stack End

Im so confused why I can't use a table, Im trying to make a overhead GUI and it includes a Division Part/GUI (See the last part of the script) Anyone can tell me how to use tables in the correct way for this to work?

1 answer

Log in to vote
1
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Since a table is not a string, it cannot be combined with a string with concatenation. If you wanted to convert every value in the table to a string and combine them, you can use the table.concat function. For example:

Clone2.TextLabel.Text = "Division: " .. table.concat(DivisionTable,", ")

this line will combine the DivisionTable into a single string, with each value separated by a comma.

Also for the rest of the script, you should properly indent it to ensure that it functions in the right order/way that you want it to. As well as this, you spelt "Guest" wrong when you check if the player is a guest in the group. Also keep in mind that anything created by a LocalScript (which this should be) will only be visible to the LocalPlayer. You will have to use remote events if you want every player to be able to see the billboard (you can look into that more here).

Hope this helps!

0
Couldn't you also unpack the table as well. but yeah concat is easier User#19524 175 — 5y
0
I think this is well answered thanks! numercookie13246 11 — 5y
Ad

Answer this question