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

How Can I Teleport The Random Chosed Player?

Asked by 5 years ago

I'm Doing a Simon Says Game, So The Script Chooses a Random Player to be Simon, But I'm Struggling in how to Teleport Simon to a different place, I Want to Teleport Only Simon, I'm Trying CFrame but it doesn't work.

local s = script.Stat


t= 0
while true do
    t= 8
    repeat
        t= t-1
        s.Value = "Game Starting in "..t
        wait(1)     
    until t == 0


target = CFrame.new(102, 3.5, -465)
for i, player in pairs(game.Players:GetChildren()) do
    player.Character.UpperTorso.CFrame = target
end
    wait(1)

    t= 5
    repeat 
        t= t-1
        s.Value = "Choosing Simon in "..t
        wait(1)
    until t == 0
    local randomPlayer = game.Players:GetPlayers()
    [math.random(1,#game.Players:GetPlayers())]
    print(randomPlayer.Name)
randomPlayer.TeamColor = BrickColor.new("Black")

simonpl = CFrame.new(182, 2.5, -477)
randomPlayer.CFrame = simonpl
end
    print("this is working")
end
    print("This Is Simon")

print("game ended")
0
Have you attempted searching key words like "teleport" on this website? I'm sure hundreds of players have had similar questions alphawolvess 1784 — 5y
0
Yes, But No One Is Like My Case ItzJester2 12 — 5y
0
any output errors? Le_Teapots 913 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Edited script:

local s = script.Stat


t= 0
while true do
    t= 8
    repeat
        t= t-1
        s.Value = "Game Starting in "..t
        wait(1)     
    until t == 0


target = CFrame.new(102, 3.5, -465)
for i, player in pairs(game.Players:GetChildren()) do
    player.Character.HumanoidRootPart.CFrame = target ----
end
    wait(1)

    t= 5
    repeat 
        t= t-1
        s.Value = "Choosing Simon in "..t
        wait(1)
    until t == 0
    local randomPlayer = game.Players:GetPlayers()
    [math.random(1,#game.Players:GetPlayers())]
    print(randomPlayer.Name)
randomPlayer.TeamColor = BrickColor.new("Black")

simonpl = CFrame.new(182, 2.5, -477)
randomPlayer.Character.HumanoidRootPart.CFrame = simonpl ----
end
    print("this is working")
end
    print("This Is Simon")

print("game ended")

In line 16 replaced UpperTorso with HumanoidRootPart, its a better practice to use this body part to move the character around.

In line 32 you should reference the character's HumanoidRootPart, not the player.

0
This Works, Thanks! Can I Know How Can I Print The Player Names? Like To Say: [playername] Is Simon ItzJester2 12 — 5y
0
Considering 'randomPlayer' is simon, you would include the following in your code: print(randomPlayer.Name .. " is Simon") Le_Teapots 913 — 5y
Ad

Answer this question