So I'm making this game for my father because he loves this Xbox game and wants to recreate it in Roblox so I'm coding it for him but I ran into a problem, The MainFramework script is not looping, So can anyone help me? I'd really appreciate it!
-- Variables
local replicatedStorage = game:GetService("ReplicatedStorage")
local Marbles = workspace:WaitForChild("Marbles"):GetChildren()
local Status = replicatedStorage:WaitForChild("Status")
local playersNeeded = 1
local plates = workspace:WaitForChild("Plates"):WaitForChild("Plates")
local cleanUpModule = require(script.CleanUpScript)
-- Game Loop
while true do
Status.Value = "Waiting for enough players to start!"
repeat wait(1) until game.Players.NumPlayers >= playersNeeded
Status.Value = "Intermission!"
wait(5)
local playersAlive = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(playersAlive, player)
end
wait(5)
local AvailableSpawnPoints = workspace:WaitForChild("SpawnPoints"):WaitForChild("SpawnPoints"):GetChildren()
for i, players in pairs(game.Players:GetPlayers()) do
character = player.Character
character.HumanoidRootPart.CFrame = AvailableSpawnPoints[1].CFrame
AvailableSpawnPoints[1]:Destroy()
end
Status.Value = "Get Ready to play!"
wait(5)
Marbles.Anchored = false
plates.Plate1.Transparency = 1
plates.Plate1.CanCollide = false
plates.Plate2.Transparency = 1
plates.Plate2.CanCollide = false
plates.Plate3.Transparency = 1
plates.Plate3.CanCollide = false
plates.Plate4.Transparency = 1
plates.Plate4.CanCollide = false
for i,v in pairs(playersAlive) do print(i,v) end
character.Humanoid.Died:Connect(function()
table.remove(playersAlive, table.find(playersAlive,player))
end)
if playersAlive == 2 then
Status.Value = playersAlive[1].Name.." Has won!"
playersAlive[1].leaderstats.Wins.Value = playersAlive[1].leaderstats.Wins.Value + 1
cleanUpModule.spawnBackSpawnPoints()
cleanUpModule.resetPlates()
player:LoadCharacter()
wait(2)
break
elseif playersAlive == 0 then
Status.Value = "No one wins!"
cleanUpModule.spawnBackSpawnPoints()
cleanUpModule.resetPlates()
player:LoadCharacter()
wait(2)
break
end
end
end
Module script:
local cleanup = {}
local replicatedStorage = game:GetService("ReplicatedStorage")
local plates = replicatedStorage:WaitForChild("Assets"):WaitForChild("Plates")
local spawnPoints = replicatedStorage:WaitForChild("Assets"):WaitForChild("SpawnPoints")
cleanup.spawnBackSpawnPoints = function()
local clonedSpawnPoints = spawnPoints:Clone()
clonedSpawnPoints.Parent = workspace.SpawnPoints
end
cleanup.resetPlates = function()
local clonedplates = plates:Clone()
plates.Parent = workspace.Plates
end
return cleanup

5 comments
That helps but the problem is after the plates get removed the script changes the status back to what it was first again
Oh I see.
Can you share the Module script functions named resetPlates() and spawnBackSpawnPoints() please because there might be something in the script that could cause it
ok
I don't see the problem here. Sorry.