How can I improve my performance and enhance my script?
(I’M USING ZONEPLUS V3.2.0)
So I’m making a lobby system for my horror game and I have this lobby script that handles all of the players coming out and into the teleport zones. I’m just a little confused on how I will refine the code because right now it’s not looking so good.
Code (Server Script in SSS):
-- Services
local rp = game:GetService("ReplicatedStorage")
-- Variables
local modules = rp:WaitForChild("Modules")
local zoneMod = require(modules:WaitForChild("Zone"))
-- Zones
local onePersonZone = game.Workspace:WaitForChild("TeleportOnePerson"):WaitForChild("TouchPart")
local twoPersonZone = game.Workspace:WaitForChild("TeleportTwoPeople"):WaitForChild("TouchPart")
local twoPersonZone2 = game.Workspace:WaitForChild("TeleportTwoPeople2"):WaitForChild("TouchPart")
local threePersonZone = game.Workspace:WaitForChild("TeleportThreePeople"):WaitForChild("TouchPart")
local threePersonZone2 = game.Workspace:WaitForChild("TeleportThreePeople2"):WaitForChild("TouchPart")
local fourPersonZone = game.Workspace:WaitForChild("TeleportFourPeople"):WaitForChild("TouchPart")
local fourPersonZone2 = game.Workspace:WaitForChild("TeleportFourPeople2"):WaitForChild("TouchPart")
-- Zone Variable Handlers
local oneP = zoneMod.new(onePersonZone)
local twoP = zoneMod.new(twoPersonZone)
local twoP2 = zoneMod.new(twoPersonZone2)
local threeP = zoneMod.new(threePersonZone)
local threeP2 = zoneMod.new(threePersonZone2)
local fourP = zoneMod.new(fourPersonZone)
local fourP2 = zoneMod.new(fourPersonZone2)
-- Player Entered the Zone
oneP.playerEntered:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
twoP.playerEntered:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
twoP2.playerEntered:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
threeP.playerEntered:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
threeP2.playerEntered:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
fourP.playerEntered:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
fourP2.playerEntered:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
-- Player Left the Zone
oneP.playerExited:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
twoP.playerExited:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
twoP2.playerExited:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
threeP.playerExited:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
threeP2.playerExited:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
fourP.playerExited:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)
fourP2.playerExited:Connect(function(plr: Player)
local mainZonePart = oneP["container"].Parent
end)