So i want my script to choose between some places that i choose and it gives me this error
Workspace.spawn.teleport.Script:18: bad argument #1 (Vector3 expected, got string) Stack Begin Script 'Workspace.spawn.teleport.Script', Line 18 - function onTouch Stack End
so it said like expect vector3 got string how can i fix that? here is a script
-- places i want to add for random tp
local mesto0 = Vector3.new(1,1,1)
local mesto1 = Vector3.new(2,2,2)
--choose random place
local function RN()
math.randomseed(tick())
local brojr = math.random(1)
local brojm = ("mesto"..brojr)
return brojm
end
--check if player and then tp player to random place
local function onTouch(part)
local Player = part.parent and part.parent:FindFirstChild("Humanoid") and part.parent.Humanoid.Health > 0 and game.Players:GetPlayerFromCharacter(part.parent)
if Player then
part.parent.HumanoidRootPart.CFrame = CFrame.new(RN()) --tp
print("Touched by " .. part.parent:GetFullName()) --say who touched
return Player
end
end
script.Parent.Touched:Connect(onTouch) --when touched call function onTouch
