I’m currently trying to make a game thats based and inspired by Gartic Phone, execpt in 3d.
what im trying to do here is that when someone is done doing a promt or a build the server gets this promt or build, then takes the table and alter it by one index and resend to the clients in other again, until every player has their promt read, made and repeated untill into a form thats incomprehesible, just like a telephone game, but heres the issue.
the code that “shuffles” the tables seems to be working,
but the code that shows the results doesnt seem to line up, from what i saw when play testing with a few people, i could technicly try to fix this myself, but i thought of giving this to the people who know more then me and mabye see things that i couldnt see and a little feedback.
after all this is the most importent code of the game, the game is public and you can test it out yourself if you deem helpful: Onion Telegraf - Roblox be warned, extreme indie dev feel, 1/4 baked and buggyness.
strangest thing is that i made a code that simlulates the code that showcases the builds and it seems to be working so idk whats wrong with it.
here is the code, along with the test code i made, sorry if its long, you dont need to look at everything but only the part that creates a table to show the results.
local listOfWords = { "Dog", "Cat","Burger","House","Epic","Balling","InterlockingSystem","Butterfly","Rocket","Bomb","Nuclear","Beutiful","Stratagema","PSCP","Lore","Soul","Of","Cinder","Love","Car","Team","Person","Existence","Why","Who","Bro","When","PlinPlinPlon" } local function giveStartPromt() local tablo = {} for i=1, math.random(3,6) do table.insert(tablo,listOfWords[math.random(1,#listOfWords)]) end return table.concat(tablo,"_") end local nextfinishedpromt = false local rounds = {} local startOfPlayers local numOfPlayers local normalmode_desctext = "write what you think you see,<br />once sended no going back" local normalmode_impacentText = "you really take alot to process isnt it?" RS.Remotes.startGame.OnServerEvent:Connect(function() if onGoingGame then print("game goin silly") return end onGoingGame = true table.clear(rounds) for roundnum = 1, #game.Players:GetChildren() do --1 = promts --2 = places rounds[roundnum] = { {}, {} } --get promts local howManyVoted = 0 if roundnum == 1 then numOfPlayers = #game.Players:GetChildren() for _, player:Player in game.Players:GetChildren() do task.spawn(function() local success, promtthing = pcall(function() return RS.Remotes.getPromtsForServer:InvokeClient(player,nil,"write a promt for someone idk",normalmode_impacentText) end) --local promtthing = RS.Remotes.getPromtsForServer:InvokeClient(player) --rounds[roundnum][player] = promtthing --why dodesnt it # the values AHHHHHH if success then if promtthing == "" then promtthing = giveStartPromt() end table.insert(rounds[roundnum][1],{player.UserId,promtthing,true}) else numOfPlayers -= 1 warn("got error prop left idk: "..promtthing) end --client prob left the server RS.Remotes.sendPlayersReadyOfPromt:FireAllClients(#rounds[roundnum][1],numOfPlayers) end) end startOfPlayers = numOfPlayers else local firstTolast local lastguy for i, tableplayer in rounds[roundnum-1][2] do if not lastguy then lastguy = tableplayer firstTolast = tableplayer continue end --i should ve drank water this boggy bugy me out task.spawn(function() local isAlive = tableplayer[3] --idk if i should make a system if they can come back if they disconnected.. eh why not local success, promtthing = pcall(function() return RS.Remotes.getPromtsForServer:InvokeClient(game.Players:GetPlayerByUserId(tableplayer[1]),lastguy[2],normalmode_desctext,normalmode_impacentText) end) if success and not isAlive then --this guy resurected numOfPlayers += 1 warn("no way he came back") elseif not success and isAlive then --this guy died you barnical how could you numOfPlayers -= 1 warn("got error prob left or has left idk: "..promtthing) promtthing = rounds[roundnum-1][1][i] end --client prob left the server table.insert(rounds[roundnum][1],{tableplayer[1],promtthing,success}) RS.Remotes.sendPlayersReadyOfPromt:FireAllClients(#rounds[roundnum][1]-(startOfPlayers-numOfPlayers),numOfPlayers) --#rounds[roundnum-1][2]) --numOfPlayers? end) lastguy = tableplayer end task.spawn(function() local isAlive = firstTolast[3] --idk if i should make a system if they can come back if they disconnected.. eh why not local success, promtthing = pcall(function() return RS.Remotes.getPromtsForServer:InvokeClient(game.Players:GetPlayerByUserId(firstTolast[1]),lastguy[2],normalmode_desctext,normalmode_impacentText) end) --rounds[roundnum][player] = promtthing --why dodesnt it # the values AHHHHHH if success and not isAlive then --this guy resurected numOfPlayers += 1 warn("no way he came back") elseif not success and isAlive then --this guy died you barnical how could you numOfPlayers -= 1 warn("got error prob left or has left idk: "..promtthing) promtthing = rounds[roundnum-1][1][1] end --client prob left the server table.insert(rounds[roundnum][1],{firstTolast[1],promtthing,success}) end) end repeat task.wait() until #rounds[roundnum][1] == startOfPlayers print(rounds) print("finished writing promts") --give promts local firstTolast local lastguy for i, tableplayer in rounds[roundnum][1] do --should i store it in a table or run the same for loop? this is future me at bed time i have no idea what this guy talkin about if not lastguy then lastguy = tableplayer firstTolast = tableplayer continue end local playerstuff = game.Players:GetPlayerByUserId(tableplayer[1]) if playerstuff then RS.Remotes.sendPromt:FireClient(playerstuff,lastguy[2]) end lastguy = tableplayer end local playerstuff = game.Players:GetPlayerByUserId(firstTolast[1]) if playerstuff then RS.Remotes.sendPromt:FireClient(playerstuff,lastguy[2]) end print("building started") waitTimer(globalGamemodeSettings.timeForBuildingInSeconds) print("building ended") local firstTolast local lastguy for i, tableplayer in rounds[roundnum][1] do if not lastguy then lastguy = tableplayer firstTolast = tableplayer continue end if not tableplayer[1] then numOfPlayers -= 1 continue end task.spawn(function() local isAlive = tableplayer[3] local success, palcething = pcall(function() return RS.Remotes.getPlacesForServer:InvokeClient(game.Players:GetPlayerByUserId(tableplayer[1])) end) if success and not isAlive then --this guy resurected numOfPlayers += 1 warn("no way he came back") elseif not success and isAlive then --this guy died you barnical how could you numOfPlayers -= 1 warn("got error prob left or has left idk: "..palcething) palcething = rounds[roundnum-1][1][i] end --client prob left the server table.insert(rounds[roundnum][2],{tableplayer[1],palcething,success}) end) lastguy = tableplayer end task.spawn(function() local isAlive = firstTolast[3] local success, palcething = pcall(function() return RS.Remotes.getPlacesForServer:InvokeClient(game.Players:GetPlayerByUserId(firstTolast[1])) end) if success and not isAlive then --this guy resurected numOfPlayers += 1 warn("no way he came back") elseif not success and isAlive then --this guy died you barnical how could you numOfPlayers -= 1 warn("got error prob left or has left idk: "..palcething) palcething = rounds[roundnum-1][1][1] end --client prob left the server table.insert(rounds[roundnum][2],{firstTolast[1],palcething}) end) repeat task.wait() until #rounds[roundnum][2] == startOfPlayers print(rounds) print("one round finished") end print("makin fnished now time to show em") local finishedRounds = {} for i, round in rounds do if i == 1 then for i, playerpromt in round[1] do finishedRounds[i] = {} end end local thing = {} for i, promthing in round[1] do thing[i] = {} table.insert(thing[i],{promthing[1],promthing[2]}) end for i, promthing in round[2] do table.insert(thing[i],{promthing[1],promthing[2]}) end for i, thingytning in thing do table.insert(finishedRounds[i],thingytning) end end print(finishedRounds) --for i, round in rounds do -- if i == 1 then -- for i, playerpromt in round[1] do -- finishedRounds[i] = {} -- end -- end -- for i, promthing in round[1] do -- table.insert(finishedRounds[i],{1,promthing[1],promthing[2]}) -- end -- for i, promthing in round[2] do -- table.insert(finishedRounds[i],{2,promthing[1],promthing[2]}) -- end --end for iron, roundabout in finishedRounds do for i, thing in roundabout do local a if iron == 1 and i == 1 then a = 1 end repeat task.wait() until nextfinishedpromt or a if i == 1 and a ~= 1 then a = 2 end if iron == #finishedRounds and i == #roundabout then a = 3 end RS.Remotes.sendFinishedPromtToPlayers:FireAllClients(thing, a,nextfinishedpromt) nextfinishedpromt = false end end print("game finished!111") onGoingGame = false end) local rounds = {} local playersTest = {} local function addTestPlayer(name) local a = Instance.new("StringValue") a.Name = name table.insert(playersTest,a) end addTestPlayer("Player1") addTestPlayer("Player2") addTestPlayer("Player3") local function givePromt(strin) return strin..1 end local function testRoundSytem() table.clear(rounds) for roundnum = 1, #playersTest do --1 = promts --2 = places rounds[roundnum] = { {}, {} } --get promts if roundnum == 1 then for _, player in playersTest do task.spawn(function() local promtthing = giveStartPromt() --RS.Remotes.getPromtsForServer:InvokeClient(player) --rounds[roundnum][player] = promtthing --why dodesnt it # the values AHHHHHH table.insert(rounds[roundnum][1],{player,promtthing}) --RS.Remotes.sendPlayersReadyOfPromt:FireAllClients(#rounds[roundnum][1],#game.Players:GetChildren()) end) end else local firstTolast local lastguy for i, tableplayer in rounds[roundnum-1][2] do if not lastguy then lastguy = tableplayer firstTolast = tableplayer continue end --i should ve drank water this boggy bugy me out task.spawn(function() local promtthing = givePromt(lastguy[2]) --RS.Remotes.getPromtsForServer:InvokeClient(tableplayer[1],lastguy[2]) --rounds[roundnum][player] = promtthing --why dodesnt it # the values AHHHHHH table.insert(rounds[roundnum][1],{tableplayer[1],promtthing}) --RS.Remotes.sendPlayersReadyOfPromt:FireAllClients(#rounds[roundnum][1],rounds[roundnum-1][2]) end) lastguy = tableplayer end task.spawn(function() local promtthing = givePromt(lastguy[2]) --RS.Remotes.getPromtsForServer:InvokeClient(firstTolast[1],lastguy[2]) --rounds[roundnum][player] = promtthing --why dodesnt it # the values AHHHHHH table.insert(rounds[roundnum][1],{firstTolast[1],promtthing}) end) end repeat task.wait() until #rounds[roundnum][1] == #playersTest print(rounds) print("finished writing promts") --give promts local firstTolast local lastguy for i, tableplayer in rounds[roundnum][1] do --should i store it in a table or run the same for loop? if not lastguy then lastguy = tableplayer firstTolast = tableplayer continue end print("sended promt "..lastguy[2].."by "..lastguy[1].Name.."to"..tableplayer[1].Name)--RS.Remotes.sendPromt:FireClient(tableplayer[1],lastguy[2]) lastguy = tableplayer end print("sended promt "..lastguy[2].."by "..lastguy[1].."to"..firstTolast[1])--RS.Remotes.sendPromt:FireClient(firstTolast[1],lastguy[2]) print("building started") waitTimer(globalGamemodeSettings.timeForBuildingInSeconds) print("building ended") local firstTolast local lastguy for i, tableplayer in rounds[roundnum][1] do if not lastguy then lastguy = tableplayer firstTolast = tableplayer continue end task.spawn(function() local palcething = "building of "..tableplayer[1].Name --RS.Remotes.getPlacesForServer:InvokeClient(tableplayer[1]) table.insert(rounds[roundnum][2],{tableplayer[1],palcething}) end) lastguy = tableplayer end task.spawn(function() local palcething = "building of "..firstTolast[1].Name --RS.Remotes.getPlacesForServer:InvokeClient(firstTolast[1]) table.insert(rounds[roundnum][2],{firstTolast[1],palcething}) end) repeat task.wait() until #rounds[roundnum][2] == #playersTest print(rounds) print("one round finished") end print("makin fnished now time to show em") local finishedRounds = {} for i, round in rounds do if i == 1 then for i, playerpromt in round[1] do finishedRounds[i] = {} end end local thing = {} for i, promthing in round[1] do thing[i] = {} table.insert(thing[i],{promthing[1],promthing[2]}) end for i, promthing in round[2] do table.insert(thing[i],{promthing[1],promthing[2]}) end for i, thingytning in thing do table.insert(finishedRounds[i],thingytning) end end print(finishedRounds) --for i, round in rounds do -- if i == 1 then -- for i, playerpromt in round[1] do -- finishedRounds[i] = {} -- end -- end -- for i, promthing in round[1] do -- table.insert(finishedRounds[i],{1,promthing[1],promthing[2]}) -- end -- for i, promthing in round[2] do -- table.insert(finishedRounds[i],{2,promthing[1],promthing[2]}) -- end --end for iron, roundabout in finishedRounds do for i, thing in roundabout do local a if iron == 1 and i == 1 then a = 1 end task.wait(1)--repeat task.wait() until nextfinishedpromt or a if i == 1 and a ~= 1 then a = 2 end nextfinishedpromt = false if iron == #finishedRounds and i == #roundabout then a = 3 end if a == 1 then print("time up, Lets take a look *rubs hands*") print(" Album i think, use /next to next") elseif a == 2 then print(thing[1][1].Name.." Album i think, use /next to next") elseif a == 3 then print("i think thats it") else print("nexted") end print(thing[1][1]..": "..thing[1][2]) task.wait(2) print(thing[2][1]..": "..thing[1][2]) --RS.Remotes.sendFinishedPromtToPlayers:FireAllClients(thing, a) end end print("game finished!111") end Sorry if this post is bad, its my first post and im abusing the excuse that english is not my first language (dispite using it more then my native one)
Most importent: please ignore my comments