Here's the script:
local repstorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
function pickPLR()
local plrlist = players:GetChildren()
local selectedIndex = math.random(1,#plrlist)
local target = CFrame.new(158.5, 44.5, 77.5)
selectedIndex.Character.HumanoidRootPart.CFrame = target
end
while true do
wait(5)
pickPLR()
wait(50)
end
Now when I test this it tells me "Attempt to index local 'selectedIndex' (a number value)"
Can anyone tell me what i'm doing wrong? The point of the script is to select a random player and teleport only that player to the target area.

1 comment
what you're doing wrong is trying to use selectedindex which is actually just a number value as the player.