Effectively, what I’m trying to achieve here is a script that will decide on two unique players in the workspace and teleport them to two opposing corners of a boxing ring.
However, I’ve been told that my way of going about this is quite inefficient and I’m not really sure how: I’ve tried a few ways of performing this but I can’t seem to rack my brain around it
The script goes as follows:
local Players = game.Players:GetChildren()()
local Chosen1, Chosen2 = math.random(1, #Players), 0
repeat Chosen2 = math.random(1, #Players) until Chosen2 ~= Chosen1
Chosen1.Character.HumanoidRootPart.CFrame = Corner1.CFrame
Chosen2.Character.HumanoidRootPart.CFrame = Corner2.CFrame
I’m not necessarily asking for anyone to write a full script for me, just some advice in optimising this script: any help would be appreciated; thanks!
local Players = game.Players:GetChildren()() --Extra ()
Chosen1.Character.HumanoidRootPart.CFrame = Corner1.CFrame
Chosen2.Character.HumanoidRootPart.CFrame = Corner2.CFrame --Character is not a child of a number