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

need help picking 2 different players in a teleport script?

I've been trying to make a script that picks two random players and teleports them to different spawns in a round system. Can someone provide me their script? Mine has been not working, and I can't seem to find a fix anywhere. I got this code from a YT video and tried to edit it

local roundLength = 60
local intermissionlength = 5
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.status

local FightingSpawn = game.Workspace.FightingSpawn
local specSpawn = game.Workspace.specSpawn
local FightSpawn = game.Workspace.FightSpawn2

players = game.Players:GetChildren()

players[math.random(1, #players)]:MoveTo(Vector3.new(Location1)

)
players[math.random(1, #players:MoveTo(Vector3.new(Location2)

)


local function roundTimer()
	while wait() do
		for i = intermissionlength, 1 , -1 do
			InRound.Value = false
			wait(1)
			Status.Value = "Intermission: ".. i .. "seconds"
		end
		for i = roundLength, 1 , -1 do
			InRound.Value = true
			wait(1)
			Status.Value = "Time Left:".. i .. "seconds"
		end
	end
end
spawn(roundTimer)

heres the script for the timer

local status = game.ReplicatedStorage.status
local Timer = script.Parent.Timer
status.Changed:Connect(function()
	Timer.Text = status.Value
end)

2 comments

0

It should work, does it have any errors?

0

line 15: you are missing a parenthesis and bracket

1 answer

Your issue is quite simple. You're trying to call the :MoveTo() method of Model on a Player Object. This of which isn't an existing method of it's class. You'll need to reference the Character rig to call this function on to actively adjust it's position properly:

wait()

local Players = game:GetService("Players"):GetPlayers()

local Player = Players[math.random(#Players)]
local Character = Player.Character or Player.CharacterAdded:Wait()

Character:MoveTo(workspace.Part.Position)

7 comments

0

its not working, correct me if im doing something wrong local Players = game:GetService("Players"):GetPlayers() Players[math.random(1, #Players)].Character:MoveTo(FightingSpawn)

0

You need to provide the Vector3 Pos: FightingSpawn.Position

0

bad argument #2 (interval is empty) got this error from this script : Players[math.random(1, #Players)].Character:MoveTo(FightingSpawn.Position)

0

Try the code above

0

The one you posted doesn't work

0

Works just fine for me

0

can you post exact code for me to try?

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