I have this function that loops through a folder that hold the players turn order via string values named 'Player1', 'Player2', 'Player3',etc. all the way up to 'Player8'. If the value is empty then the value is removed via a different script. but thats not the issue. Whenever i check for the players name then return the players name and attempt to print the function i get the error ServerStorage.doTurn:31: attempt to concatenate a nil value
This is the function:
local RS = game:GetService("ReplicatedStorage") local TurnNum = RS.Turn local function getPlayerTurn() for i,v in pairs(RS.PlayerOrder:GetChildren()) do print(TurnNum.Value) if v.Name == 'Player'.. tostring(TurnNum.Value) then print(v.Name) return v.Name else TurnNum.Value = TurnNum.Value + 1 wait() getPlayerTurn() end end end print(getPlayerTurn().."'s turn")
EDIT: TurnNum gets set to 1 when it reaches 9(making it range from 1 - 8)
So Im not completely sure but try
local RS = game:GetService("ReplicatedStorage") local TurnNum = RS.Turn
local Name local function getPlayerTurn() for i,v in pairs(RS.PlayerOrder:GetChildren()) do print(TurnNum.Value) if v.Name == 'Player'.. tostring(TurnNum.Value) then print(v.Name) Name = v.Name else TurnNum.Value = TurnNum.Value + 1 wait() getPlayerTurn() end end return Name end print(getPlayerTurn().."'s turn")
making the name a value but as previously stated i'm not completely sure