Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

need help picking 2 different players in a teleport script?

Asked by 4 years ago
Edited 4 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

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)
0
It should work, does it have any errors? mixgingengerina10 223 — 4y
0
line 15: you are missing a parenthesis and bracket SerpentineKing 3885 — 4y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
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) PNKFALCON1 27 — 4y
0
You need to provide the Vector3 Pos: FightingSpawn.Position Ziffixture 6913 — 4y
0
bad argument #2 (interval is empty) got this error from this script : Players[math.random(1, #Players)].Character:MoveTo(FightingSpawn.Position) PNKFALCON1 27 — 4y
0
Try the code above Ziffixture 6913 — 4y
View all comments (3 more)
0
The one you posted doesn't work PNKFALCON1 27 — 4y
0
Works just fine for me Ziffixture 6913 — 4y
0
can you post exact code for me to try? PNKFALCON1 27 — 4y
Ad

Answer this question