So, this is the script for a random player chooser. The random player chooser part works, but I'm having trouble then moving the player using CFrame (SetPrimaryPartCFrame) as it keeps saying that the player I've defined doesn't exist in the workspace. Any ideas? Script is below, thanks in advance.
while script.Parent.Parent==game.Workspace.SelectedMap do --this loop does 100% work
local players = game.Players:GetPlayers()
local numPlayers = #players
local controllerPlayer
if numPlayers > 0 then
controllerPlayer = players[math.random(1, numPlayers)]
local controlName = tostring(controllerPlayer)
print(controlName)
print(tostring(controllerPlayer))
local new = CFrame.new(35.75, 1.688, -551.25)
local controllerCharacter = game.Workspace:FindFirstChild(controlName) --this is the line that throws the error
print(controllerCharacter)
controllerCharacter:SetPrimaryPartCFrame(CFrame.new(35.75, 1.688, -551.25)+Vector3.new(0,0,0))
end
break
end
