You should use attributes instead, and I would use their UserId instead of their name for extra security. I also fixed a typo I made earlier so sorry for that.
For every plate, remove that value called “Owner”, if you want to check for the owner in other scripts, just use :GetAttribute(“OwnerId”). Attributes are just massively faster to check compared to actual instances so you should always use them.
Code:
--//Services
local ServerStorage = game:GetService("ServerStorage")
local rep = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
--//Variables
local plateTemplate = ServerStorage.Player_Baseplates
local values = rep.Values
local current = values.CurrentEvent
local eventtype = current.EventType
local highlight = current.ObjectToHighlight
local status = values.Status
local currentPlates = workspace.Player_Baseplates
local inGame = workspace.Ingame
--//Controls
local RNG = Random.new()
local events = 5
local chosenEvent = ""
local ce = chosenEvent
local inRound = false
local reqPlayers = 2
--//Functions
local function chooseEvent()
chosenEvent = RNG:NextInteger(1, events)
ce = chosenEvent
end
local function executeEvent()
if ce == 1 then
eventtype.Value = "Player"
current.Value = "A player will get +10 jump power"
elseif ce == 2 then
eventtype.Value = "Player"
current.Value = "A player will become sparkly"
elseif ce == 3 then
eventtype.Value = "Arena"
current.Value = "Arena: Fire will fall from the sky"
elseif ce == 4 then
eventtype.Value = "Plate"
current.Value = "Someone's plate will light on fire"
elseif ce == 5 then
eventtype.Value = "Plate"
current.Value = "Someone's plate will flip upside-down"
end
status.Value = current.Value
end
while true do
if #players:GetPlayers() >= reqPlayers then
task.wait(1)
for i = 1, 15 do
status.Value = "Intermission: ".. 15 - i
task.wait(1)
end
if #players:GetPlayers() < reqPlayers then
continue
end
status.Value = "Teleporting players..."
--//Create all plates
currentPlates:ClearAllChildren()
for i, plate in ipairs(plateTemplate:GetChildren()) do
plate:Clone().Parent = currentPlates
end
--//Teleport players to unowned plates
for i, player in ipairs(players:GetPlayers()) do
local randomPlate = currentPlates:GetChildren()[RNG:NextInteger(1, #currentPlates:GetChildren())]
while randomPlate:GetAttribute("OwnerId") do
randomPlate = currentPlates:GetChildren()[RNG:NextInteger(1, #currentPlates:GetChildren())]
end
randomPlate:SetAttribute("OwnerId", player.UserId)
player.Character:MoveTo(randomPlate.Position)
end
--//Destroy unowned plates
for i, plate in ipairs(currentPlates:GetChildren()) do
if not plate:GetAttribute("OwnerId") then
plate:Destroy()
end
end
--//Main game
else
status.Value = "Waiting for minimum of 2 players."
players.PlayerAdded:Wait()
end
end