Can someone please help me out?

Hey guys im trying to figure out for 7 hours now why my script doesn’t work. The events don’t work, the game doesn’t reset when someone dies, and the player doesn’t get assigned a random plate. help. Can someone please find the cause of this? thx
here’s the Main Script:



local EventsModule = require(script:WaitForChild("EventsModule"))
local MethodNames = {}

for MethodName, Method in pairs(EventsModule) do
	if type(Method) == "function" then
		table.insert(MethodNames, MethodName)
	end
end



local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")

local Contestants = Teams:WaitForChild("Contestants")
local Spectators = Teams:WaitForChild("Spectators")

local Remotes = ReplicatedStorage:WaitForChild("Remotes")

local Values = ReplicatedStorage:WaitForChild("Values")
local Status = Values:WaitForChild("Status")
local GameRunning = Values:WaitForChild("GameRunning")

local Assets = ReplicatedStorage:WaitForChild("Assets")



local intermissionLength = 15
local timeBetweenEvents = 5
local minimumPlayers = 0

local function intermission()
	GameRunning.Value = false
	for i = intermissionLength, 0 , -1 do
		wait(1)
		Status.Value = "Intermission: ".. i .." seconds"
	end
	Status.Value = "Round Starting!"
	GameRunning.Value = true
end

local function startRound()
	
	
	
	local Plates = Assets.plates:Clone()
	Plates.Parent = game.Workspace
	
	local Players = game.Players:GetPlayers()
	local PlayersAlive = {}
	local PlatesAlive = {}
	
	
	
	for i, player in pairs(Players) do
		local plate = Plates:FindFirstChild("i"..i)
		local character = player.Character
		
		local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
		if HumanoidRootPart and #Players >= minimumPlayers then
			HumanoidRootPart.CFrame = plate.PrimaryPart.CFrame * CFrame.new(0,3,0)
			player.serverData.playerPlate.Value = i
			
			local plateOwner = Instance.new("StringValue")
			plateOwner.Name = "PlateOwner"
			plateOwner.Value = player.Name
			plateOwner.Parent = plate
			
			player.Team = Contestants
			table.insert(PlayersAlive, player)
			table.insert(PlatesAlive, plate)
			for i, v in pairs(PlayersAlive) do print(i,v) end
			
			character.Humanoid.Died:Connect(function()
				print(player.Name.. " has died")
				player.Team = Spectators
				
				table.remove(PlayersAlive, table.find(PlayersAlive, player))
				table.remove(PlatesAlive, table.find(PlatesAlive, plate))
			end)
		else
			Status.Value = "Not enough players to start the game.."
		end
	end
	
	for i, plate in pairs(Plates:GetChildren()) do
		local plateOwner = plate:FindFirstChild("plateOwner")
		if not plateOwner then
			print("there is no owner")
			plate:Destroy()
		end
	end
	
	while #PlayersAlive > 0 do
		wait(timeBetweenEvents)
		
		local RandomMethodName = MethodNames[math.random(1, #MethodNames)]
		local Method = EventsModule[RandomMethodName]
		Method()
	end
	
	
	Plates:Destroy()
end

while true do
	intermission()
	startRound()
end

here’s the events script:

local Events = {}



local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Assets = ReplicatedStorage:WaitForChild("Assets")

local Values = ReplicatedStorage:WaitForChild("Values")
local Status = Values:WaitForChild("Status")

local function pickRandomPlayerAndPlate()
	local Plates = game.Workspace:WaitForChild("Plates")
	local allPlates = Plates:GetChildren()
	local plate = allPlates[math.random(1,#allPlates)]
	
	local playerName = plate.plateOwner.Value
	local player = game.Players:FindFirstChild(playerName)
	return player, plate
end

Events.shrinkPlate2Stunds = function(player, plate)
	if player == nil and plate == nil then
		local player, plate = pickRandomPlayerAndPlate()
		if player and plate then
			plate.Size = plate.Size - Vector3.new(2,0,2)
			Status.Value = player.Name.. "'s plate shrunk by 2 studs!"
		end
	else 
		plate.Size = plate.Size - Vector3.new(2,0,2)
		Status.Value = player.Name.. "'s plate shrunk by 2 studs!"
	end
end

Events.shrinkPlate5Studs = function(player, plate)
	if player == nil and plate == nil then
		local player, plate = pickRandomPlayerAndPlate()
		if player and plate then
			plate.Size = plate.Size - Vector3.new(5,0,5)
			Status.Value = player.Name.. "'s plate shrunk by 5 studs!"
		end
	else
		plate.Size = plate.Size - Vector3.new(5,0,5)
		Status.Value = player.Name.. "'s plate shrunk by 5 studs!"
	end
end

Events.growPlate2Stunds = function(player, plate)
	if player == nil and plate == nil then
		local player, plate = pickRandomPlayerAndPlate()
		if player and plate then
			plate.Size = plate.Size + Vector3.new(2,0,2)
			Status.Value = player.Name.. "'s plate gre by 2 studs!"
		end
	else 
		plate.Size = plate.Size + Vector3.new(2,0,2)
		Status.Value = player.Name.. "'s plate grew by 2 studs!"
	end
end

Events.growPlate5Studs = function(player, plate)
	if player == nil and plate == nil then
		local player, plate = pickRandomPlayerAndPlate()
		if player and plate then
			plate.Size = plate.Size + Vector3.new(5,0,5)
			Status.Value = player.Name.. "'s plate grew by 5 studs!"
		end
	else
		plate.Size = plate.Size + Vector3.new(5,0,5)
		Status.Value = player.Name.. "'s plate grew by 5 studs!"
	end
end

return Events

3 Likes

Quick Questions


  1. So if somebody dies the entire event resets? or if everyone is dead?
  2. What exactly is the random plate supposed to do?
6 Likes