Math.Random 50/50

i am trying to make a player.Character.Parent that teleport teleport unto folder but split

local pep = math.random(game.Workspace.Tug1,game.Workspace.Tug2)

that two is a folder and i got error

 ServerScriptService.Script:119: invalid argument #1 to 'random' (number expected, got Instance)

i want to achieve that when the timer stop but i already made one so when the timers stop the players Parent will teleport split unto the folder

local pep = math.random()
if pep > 0.5 then
  player.Character.HumanoidRootPart.CFrame = workspace.Tug1.CFrame
else
  player.Character.HumanoidRootPart.CFrame = workspace.Tug2.CFrame
end
1 Like

The Tug1 and Tug2 are folder and i want to achieve that the players Parent will change into Tug1 or Tug2

Math.random only accepts numbers

So you can make something like

local random = math.random(1,2)
if random == 1 then
     -- do something
else
     -- do something again
end
1 Like

did you forget to do this Tug1.Value and Tug2.Value

1 Like

do u have any idea on how to teleport players into split like this

local players = game.Players:GetChildren()
	for i = 1,#players do
		if players[i].Character ~= nil then
				players[i].Character.Parent = game.Workspace.Tug1 or game.Workspace.Tug2 --- this one
		end
	end

tug1 and tug 2 is not a value those are folder and i want the player teleport there

Like put players in a folder or what?

yes like that put the player into a folder but split
image

use this then lol

local teleporters = math.random(1,2)

if teleporters == 1 then

-- player teleport to point 1

print (teleporters)

end

if teleporters == 2 then

-- player teleport to point 2

print (teleporters)

end
1 Like
for i, v in pairs(game.Players:GetChildren()) do
    if v then
        local characters = v.Character
        characters.Parent = game.Workspace.Tug1 or game.Workspace.Tug2
    end
end
1 Like

you need to set the CFrame of the player’s character’s HumanoidRootPart

--teleport
player.Character.HumanoidRootPart.CFrame = Tug1.CFrame + Vector3.new(0,5,0) -- Vector3 for offset
1 Like

im teleporting the Character’s player model into Folder not humanoidRP.Cframe :slight_smile:

He wants to put the players in 1 folder

i wanna put the player into 2 folder

I literally don’t understand this thread, no one is speaking clearly in english

local val = math.random(1,2)

if val == 1 then
    for i, v in pairs(game.Players:GetChildren()) do
    if v then
        local characters = v.Character
        characters.Parent = game.Workspace.Tug1
    end
end
elseif val == 2 then
    for i, v in pairs(game.Players:GetChildren()) do
    if v then
        local characters = v.Character
        characters.Parent = game.Workspace.Tug2
    end
end
end
2 Likes

That’s not called teleporting that’s called moving the character model, I’m pretty you can’t/aren’t supposed to move the players character model.

If you want to group different players for different things, create tables and put the player instance or character instance in the tables, you can even use ObjectValues if you want.

There is no need to be moving around the character model.

2 Likes

use this it will work as the players in Folder

local Folder =    ""---------- the place you want be player in
local Value = Instance.new("ObjectValue",Folder )
        Value.Value = Player
        Value.Name = Player.Name

easy dont think this?

1 Like

ill make it clear I want the Player move into 2 folder like
there is 2 player the one player is going to teleport into 1 folder and the other player is going to teleport into 2 folder

1 Like