Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isnt CFrame working properly?

I am trying to pick a random CFrame from a table so the players can teleport to a random CFrame...

local Ceev= {CFrame.new(-6601.1, 216.5, 137.8),CFrame.new(-6685.1, 216.5, 187.2)}
local Ctarget = math.random(#Ceev)
print(Ctarget)
for i, player in pairs(game.Players:GetPlayers()) do
 player.Character.Torso.CFrame = Ctarget + Vector3.new( 0 * math.random(1, 2) , 0 * 2 , i * 2)
end

1 answer

✓ Accepted answer

You haven't set Ctarget to one of the values in Ceev, you've set it to a random number up to the number of values in Ceev. You need to do Ceev[math.random(1,#Ceev)] to do this correctly.

local Ceev= {CFrame.new(-6601.1, 216.5, 137.8),CFrame.new(-6685.1, 216.5, 187.2)}
local Ctarget = Ceev[math.random(1,#Ceev)]
print(Ctarget)
for i, player in pairs(game.Players:GetPlayers()) do
	player.Character.Torso.CFrame = Ctarget + Vector3.new( 0 * math.random(1, 2) , 0 * 2 , i * 2)
end

Hope this works for you!

This discussion is preserved as it was. New answers, comments, and votes are closed.