I was looking for a teleport script in public models to learn more about it. I found a working one and tried to copy it over and it ended up not working. So I literally copy and pasted it to see if it would work that way. But unfortunately not. It is printing everything but "wow" and "We Did It Bois" In my output. I have two parts inside of a model named "Teles" these parts are named "teleport1" and "teleport2". This is Teleport 1's script. It always returns with
Koala
lel
cool
nil
No Telelocation
I have literally looked over this hundreds of times looking for whats wrong but I can't get a hold of it. It looks as if it can't find the child of Tele named as "teleport2". As it is returning with "nil".
function onTouched(part)
if part.Parent ~= nil then
print("Koala")
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
print("lel")
local teleportfrom=script.Parent.Enabled.Value
if teleportfrom~=0 then
print("cool")
if h==humanoid then
print("wow")
return
end
local teleportto=script.Parent.Parent:FindFirstChild("teleport2")
print(teleportto)
if teleportto~=nil then
print("We Did It Bois")
local torso = h.Parent.Torso
local location = {teleportto.Position}
local i = 1
local x = location[i].x
local y = location[i].y
local z = location[i].z
x = x + math.random(-1, 1)
z = z + math.random(-1, 1)
y = y + math.random(2, 3)
local cf = torso.CFrame
local lx = 0
local ly = y
local lz = 0
script.Parent.Enabled.Value=0
teleportto.Enabled.Value=0
torso.CFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(lx,ly,lz))
wait(3)
script.Parent.Enabled.Value=1
teleportto.Enabled.Value=1
else
print("No telelocation")
end
end
end
end
end
script.Parent.Touched:connect(onTouched)

2 comments
What is your script trying to do?
Teleport a player from "teleport1" to "teleport2".