hello! i am having trouble with a specific function. i've verified that everything else works, it's just this part of the minigame handler i am currently working on. i'm calling the function each time a player leaves or dies in a round, verifying that it updates.
"inround" is a table im adding and removing players to, in order to manage a round.
server script;
local win = repstr:WaitForChild("PlayerWin") function findwin() if #inround == 1 then print(unpack(inround)) -- for checking win:FireAllClients(inround, 1) end end
local script;
local hintbar = script.Parent.ScreenGui.TextLabel game.ReplicatedStorage.PlayerWin.OnClientEvent:Connect(function(inround) hintbar.Text = inround.. " has won the round!" end)
the error is on this line;
hintbar.Text = inround.. " has won the round!"
specifically, it says "attempt to concatenate table with string". any help would be greatly appreciated!
The problem is, that inround value is a table. You have to convert it to a string. You can do this to fix the problem
inround[Player]
local hintbar = script.Parent.ScreenGui.TextLabel game.ReplicatedStorage.PlayerWin.OnClientEvent:Connect(function(Player) hintbar.Text = (Player.." has won the round!") end)
inround
still remains an Array, you’re essentially trying to mend an Object to a string, which is causing controversy. To attain a properly extract and format a string of all the "contestants" within the array, you can use the table.concat()
function, and pass the separation argument with a whitespace.
local Text = table.concat(Array, ' ').." has won the game!"