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

PLAYERS DO NOT TELEPORT?

Hi Thank You for your time i have a problem i want every player to move or teleport to different maps but it does not work and sometimes it does glitches here is the code i have different surfaces and every 30 seconds i want to teleport to the another map.

for y,players in pairs(plrs) do
			for i,surface in pairs(surfaces) do
			
				local gamecharacter=players.Character or players.CharacterAdded:Wait()
				if gamecharacter then
				
					local surfacespowns=surface:FindFirstChild("Spown"):GetChildren()
					wait(1)
					gamecharacter:FindFirstChild("HumanoidRootPart").CFrame=surfacespowns[math.random(1,#surfacespowns)].CFrame						
					game:GetService("ReplicatedStorage").Desider.CanCollide=false
					wait(30)
				else
					if not players then

						table.remove(plrs,i)
					end
				end
				table.remove(surfaces,i)
			end
			


		end

thank you if u have a solution please answer my question.

2 answers

✓ Accepted answer

You can use :MoveTo() to change a player/model position, please remember that your model will need to have a PrimaryPart

for y,players in pairs(plrs) do
            for i,surface in pairs(surfaces) do

                local gamecharacter=players.Character or players.CharacterAdded:Wait()
                if gamecharacter then

                    local surfacespowns=surface:FindFirstChild("Spown"):GetChildren()
                    wait(1)
                    gamecharacter:MoveTo(surfacespowns[math.random(1,#surfacespowns)].CFrame.position)                     
                    game:GetService("ReplicatedStorage").Desider.CanCollide=false
                    wait(30)
                else
                    if not players then

                        table.remove(plrs,i)
                    end
                end
                table.remove(surfaces,i)
            end



        end

15 comments

0

hey thanks but on this line gamecharacter:MoveTo(surfacespowns[math.random(1,#surfacespowns)].Position) it gives me this error attempt to index number with 'Position'

1

Try it now, I edited the answer

0

ok

0

it gave me attempt to index number with 'CFrame'

0

can you explain me better what surfacespoints is? I need to know to fix the answer [If possible add it on the question]

0

servicespowns is a list of spwns in that map

0

spawns you mean the part?

0

no real spown points

0

so vector3 positions or CFrame? [If one of thease, please specify]

0

cframes

0

how do i know i guess vector3

0

Add the variable at the question so I can see it, it will be easyer to fix

0

hi suurfacespown is a model in each surface local surfacespowns=surface:FindFirstChild("Spown"):GetChildren() and then i get a random spownpoint from that model and then try to teleport all players to random spownpoint in the map with is in the spownpoints model ans thank u for trying to solve my problem learmir

0

hi thank u this line solved everything character:FindFirstChild("HumanoidRootPart").CFrame=allspowns[math.random(1,#allspowns)].CFrame

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