This thread is… interesting…
I want to address a few things before answering your query.
-
Teleport typically refers to one of two things in Roblox - the transportation of the player from one game server to another. Or, moving the player’s character in 3D space (like in the movie Jumper)
-
You need to validate your code - the Error you mention clearly states there’s a problem with the math.random function. You need to check the requirements for a function, which you can do on the Developer Hub (developer.roblox.com), or add print functions to check your values to validate what you’re inputting.
-
Lastly, this is for all @here who replied - Please read the question very carefully - if you didn’t understand the question the first time - read it again, if you still don’t understand, ask questions - don’t provide solutions to a problem you don’t understand. It confuses the situation for our fellow developer seeking help.
I am guilty of reading too quickly and not fully understanding a topic as well, but its good to acknowledge when you’re confused by the question.
As for your query, if I understand correctly.
You want to randomly (50/50 chance) set the player Character’s Parent to either Tug1 or Tug2 in workspace?
local pep = math.random() == 1 and game.Workspace.Tug1 or game.Workspace.Tug2
--this works by checking if the value returned by math.random() is equal to 1 or 0.
-- if this statement is true, the pep will equal Tug1
-- otherwise, the pep will equal Tug2
-- this is the same as...
local pep = game.Workspace.Tug1
if (math.random() == 1) then
pep = game.Workspace.Tug2
end
I presume after this script you are using the variable pep to set the Character’s Parent.
If not, you should include the rest of the 118 + lines of code in your script so we have the full context of what you’re attempting to do.
Anyway, I’m sure someone’s already mentioned this, but the reason your random function fails is because ‘Folders’ are objects, not Numbers, which is what the function requires.
The error you receieved tells you this - the math.random function expected a Number value, but instead of an Instance value (the folder) - which is incorrect.
This is like trying to place an apple on top of a calculator and expecting the result 3 - its the wrong input.
Anyway, hope you sort out this thing.