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

How Can I Teleport The Random Chosed Player?

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")

3 comments

0

Have you attempted searching key words like "teleport" on this website? I'm sure hundreds of players have had similar questions

0

Yes, But No One Is Like My Case

0

any output errors?

1 answer

✓ Accepted answer

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.

2 comments

0

This Works, Thanks! Can I Know How Can I Print The Player Names? Like To Say: [playername] Is Simon

0

Considering 'randomPlayer' is simon, you would include the following in your code: print(randomPlayer.Name .. " is Simon")

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