Long, long, LONG script short, I'm making a board game, and at the end of the script below, there is a global table that I have created, whenever a player joins the game, or clicks "Play Game", their name is added to the table, and whenever there are 2 players in the table, the game is supposed to start. Well, I have it firing through a remote event to the server, and back to the player, but for some reason, whenever there are 2 or more players, the game doesn't start, heck it doesn't even acknowledge that the number of players in the table ever changes. Any help please?
First script is in a local script:
---Scroll down to line 173 to find the table, everything else above doesn't matter, its other stuff---
local value = script.Parent:WaitForChild("Value")
local repstorage = game:GetService("ReplicatedStorage")
local remotefolder = repstorage:WaitForChild("Remotes")
local introcamera = remotefolder:WaitForChild("IntroCamera")
local cam = workspace.CurrentCamera
local endcam = workspace:WaitForChild("EndCam")
local bg = script.Parent.Parent
local tweenservice = game:GetService("TweenService")
local start = remotefolder:WaitForChild("Start")
local endcam2 = workspace:WaitForChild("EndCam2")
local endcam3 = workspace:WaitForChild("EndCam3")
local endcam4 = workspace:WaitForChild("EndCam4")
function intro(player)
repeat
wait(1)
for i = 0, 1, 0.1 do
script.Parent.TextTransparency = i
wait()
end
wait(1)
for i = 1, 0, -0.1 do
script.Parent.TextTransparency = i
wait()
end
until script.Parent.Value.Value == true
wait(.2)
script.Parent.Text = "Loaded!"
wait(1.1)
script.Parent:TweenPosition(UDim2.new(0.15, 0, 1, 0), "In", "Back", 1)
wait(2)
script.Parent.Text = "Welcome to..."
wait(.8)
script.Parent:TweenPosition(UDim2.new(0.15, 0, 0.45, 0), "Out", "Back", 1)
wait(2.5)
script.Parent:TweenPosition(UDim2.new(0.15, 0, 1, 0), "In", "Back", 1)
wait(2)
local bg = script.Parent.Parent
for i = 0, 1, 0.02 do
bg.BackgroundTransparency = i
wait()
local movedirection = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local camcoordinates = {CoordinateFrame = endcam.CFrame}
_G.cammove = tweenservice:Create(cam, movedirection, camcoordinates)
_G.cammove:Play()
if script.Parent.Parent.Cam.Value == true then
repeat wait() until _G.cammove == Enum.PlaybackState.Completed
script.Parent.Parent.Cam.Value = false
end
end
local bloxopoly = script.Parent.Parent:WaitForChild("BLOX-OPOLY")
local play = script.Parent.Parent:WaitForChild("Play")
local spectate = script.Parent.Parent:WaitForChild("Spectate")
local store = script.Parent.Parent:WaitForChild("Store")
local clickscript1 = script.Parent.Parent.Play.Play.Play
clickscript1.Disabled = true
bloxopoly:TweenPosition(UDim2.new(0.32, 0, 0, 0), "Out", "Elastic", 1.5)
wait(.5)
play:TweenPosition(UDim2.new(0.32, 0, 0.35, 0), "Out", "Elastic", 2)
wait(.5)
spectate:TweenPosition(UDim2.new(0.32, 0, 0.56, 0), "Out", "Elastic", 2)
wait(.4)
store:TweenPosition(UDim2.new(0.32, 0, 0.77, 0), "Out", "Elastic", 2)
wait(2.5)
clickscript1.Disabled = false
spectate.Spectate.Active = true
store.Store.Active = true
repeat
wait(6)
local introcam2 = workspace:WaitForChild("IntroCam2")
local movedirection1 = TweenInfo.new(11, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local newcamcoordinates1 = {CoordinateFrame = endcam2.CFrame}
_G.cammove2 = tweenservice:Create(cam, movedirection1, newcamcoordinates1)
if script.Parent.Parent.Cam.Value == true then break end
for i = 1, 0, -0.1 do
if script.Parent.Parent.Cam.Value == true then break end
bg.BackgroundTransparency = i
wait()
end
if script.Parent.Parent.Cam.Value == true then break end
wait(1.5)
if script.Parent.Parent.Cam.Value == true then break end
for i = 0, 1, 0.04 do
if script.Parent.Parent.Cam.Value == true then break end
bg.BackgroundTransparency = i
wait()
if script.Parent.Parent.Cam.Value == true then break end
cam.CoordinateFrame = introcam2.CFrame
_G.cammove2:Play()
if script.Parent.Parent.Cam.Value == true then
repeat wait() until _G.cammove2 == Enum.PlaybackState.Completed
script.Parent.Parent.Cam.Value = false
end
end
wait(9)
if script.Parent.Parent.Cam.Value == true then break end
for i = 1, 0, -0.1 do
if script.Parent.Parent.Cam.Value == true then break end
bg.BackgroundTransparency = i
wait()
end
wait(3.5)
if script.Parent.Parent.Cam.Value == true then break end
cam.CoordinateFrame = workspace:WaitForChild("IntroCam3").CFrame
local movedirection2 = TweenInfo.new(13, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local newcamcoordinates2 = {CoordinateFrame = endcam3.CFrame}
_G.cammove3 = tweenservice:Create(cam, movedirection2, newcamcoordinates2)
wait(.5)
if script.Parent.Parent.Cam.Value == true then break end
for i = 0, 1, 0.1 do
if script.Parent.Parent.Cam.Value == true then break end
bg.BackgroundTransparency = i
wait()
_G.cammove3:Play()
if script.Parent.Parent.Cam.Value == true then
repeat wait() until _G.cammove3 == Enum.PlaybackState.Completed
script.Parent.Parent.Cam.Value = false
end
end
wait(11)
for i = 1, 0, -0.1 do
if script.Parent.Parent.Cam.Value == true then break end
bg.BackgroundTransparency = i
wait()
end
wait(2.5)
if script.Parent.Parent.Cam.Value == true then break end
cam.CoordinateFrame = workspace:WaitForChild("IntroCam4").CFrame
local movedirection3 = TweenInfo.new(10, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local newcamcoordinates3 = {CoordinateFrame = endcam4.CFrame}
_G.cammove4 = tweenservice:Create(cam, movedirection3, newcamcoordinates3)
wait(.5)
for i = 0, 1, 0.1 do
if script.Parent.Parent.Cam.Value == true then break end
bg.BackgroundTransparency = i
wait()
_G.cammove4:Play()
if script.Parent.Parent.Cam.Value == true then
repeat wait() until _G.cammove4 == Enum.PlaybackState.Completed
script.Parent.Parent.Cam.Value = false
end
end
if script.Parent.Parent.Cam.Value == true then break end
until script.Parent.Parent.Cam.Value == true
end
start.OnClientEvent:Connect(function()
local loadingtext = script.Parent
script.Parent:TweenPosition(UDim2.new(0.15, 0, 0.45, 0), "Out", "Back", 1)
loadingtext.Text = "Loading..."
cam.CameraType = "Follow"
local player = game.Players.LocalPlayer
cam.CameraSubject = player.Character.Humanoid
local num = 1
repeat
num = num + 1
for i = 0, 1, 0.1 do
loadingtext.TextTransparency = i
wait()
end
wait(1)
for i = 1, 0, -0.1 do
loadingtext.TextTransparency = i
wait()
end
until num == 6
script.Parent:TweenPosition(UDim2.new(0.15, 0, 1, 0), "In", "Back", 1)
wait(0.5)
for i = 0, 1, 0.02 do
bg.BackgroundTransparency = i
wait()
end
wait(2)
local turn = remotefolder:WaitForChild("TakingTurns")
_G.turntable = {}
local playersvalue = game.Players:WaitForChild("Players")
table.insert(_G.turntable, player.Name)
turn:FireServer()
end)
introcamera.OnClientInvoke = intro
Server Script:
---Turn and taking turns are the same event btw, i was too lazy to change the name of the variable in the local script above---
takingturns.OnServerEvent:Connect(function(player)
takingturns:FireClient(player)
end)
And finally, the turn script:
local repstorage = game:GetService("ReplicatedStorage")
local remotefolder = repstorage:WaitForChild("Remotes")
local takingturns = remotefolder:WaitForChild("TakingTurns")
local rolls = remotefolder:WaitForChild("Rolls")
local camera = remotefolder:WaitForChild("Camera")
local cam = workspace.CurrentCamera
takingturns.OnClientEvent:Connect(function(player)
repeat
while #_G.turntable ~= 2 do
wait()
script.Parent.Text = "Waiting for players..."
script.Parent:TweenPosition(UDim2.new(0.15, 0, 0 ,0), "Out", "Back", 1)
if #_G.turntable >= 2 then break end
end
script.Parent:TweenPosition(UDim2.new(0.15, 0, -1, 0), "In", "Back", 1)
wait(2)
local currentturn = {_G.turntable}
cam.CameraSubject = game.Players:FindFirstChild(currentturn).Character:WaitForChild("Humanoid")
local guifolder = repstorage:WaitForChild("Gui's")
local rolldice = guifolder:WaitForChild("RollDice")
local endturn = game.Players:FindFirstChild(currentturn):WaitForChild("Turn")
rolldice:Clone().Parent = game.Players:FindFirstChild(currentturn):WaitForChild("PlayerGui")
rolls.OnClientEvent:Connect(function(dice)
script.Parent:TweenPosition(UDim2.new(0.15, 0, 0, 0), "Out", "Back", 1)
wait(2)
script.Parent:TweenPosition(UDim2.new(0.15, 0, -1, 0), "In", "Back", 1)
end)
if endturn.Value ~= false then
repeat wait() until endturn.Value == true
else
return nil
end
local newturn = _G.turntable[1] + _G.turntable{currentturn}
table.remove(currentturn, 1)
wait(2)
table.insert(currentturn, _G.turntable[newturn])
until false
end)
It stops at whenever it's waiting for 2 players
