Hello, I am trying to design a teleportation script on scratch on my own; therefore, I would appreciate that you don't give me a script to copy-paste, rather give me snippets of code that I can type down myself.
My teleportation script isn't functioning properly - it's not teleporting the player. The script is designed so that when its parent part - Teleport1 - is touched, then the script will take the player and teleport it to Teleport2, another part placed on the map.
The script doesn't seem to be working properly, as once my player touches Teleport1, nothing occurs; the player just stands on the teleportation block.
Here is the script:
local Teleport1 = script.Parent
local teleport1Usable = true
if teleport1Usable then
print("a")
teleport1Usable.BrickColor = BrickColor.new("Eggplant")
else
print("b")
teleport1Usable.BrickColor = BrickColor.new("Really red")
wait()
end
function onTouch(part)
print("A")
local humanoid = part.Parent:FindFirstChild("Humanoid")
local targetPosition = game.Workspace.Teleport2.CFrame
if (humanoid ~= nil and teleport1Usable == true) then
print("B")
part.Parent.Character.Torso.CFrame = CFrame.new(246, 125.98, -59.211)
teleport1Usable = false
wait(5)
teleport1Usable = true
end
end
Teleport1.Touched:connect(onTouch)
I have already attempted:
~> Using the print() function to indicate whether certain parts of the script have worked: The only print() function that launched (which was in the console before and after I stepped on the teleporter) was print("a2").
~> Trying to use...
part.Parent.Character.Torso.CFrame = CFrame.new (targetPosition.CFrame.X, targetPosition.CFrame.Y + 5, targetPosition.CFrame.Z)
... which has lead to no avail.
I believe the problem lies in the...
Teleport1.Touched:connect(onTouch)
... line of the script, as print("A2") does not do anything once Teleport1 has been Touched.
Thanks for taking your time to read; hopefully you have an answer.

1 comment
maybe try without the function?