I have a script that will teleport avatars to another part.
local teleport1B = script.Parent.Parent.TeleportReceiver
local canTeleport = true
function TeleportA(part)
local hum = part.Parent:FindFirstChild("HumanoidRootPart")
if hum then
if canTeleport then
canTeleport = false
hum.CFrame = teleport1B.CFrame +Vector3.new(0,5,0)
wait(5)
canTeleport= true -- Sets the "Debounce" to true so it can teleport
end
end
end
script.Parent.Triggered:Connect(TeleportA)
local teleport1B = script.Parent.Parent.TeleportReceiver
local canTeleport = true
function TeleportA(part)
local hum = part.Parent:FindFirstChild("HumanoidRootPart")
if hum then
if canTeleport then
canTeleport = false
hum.CFrame = teleport1B.CFrame +Vector3.new(0,5,0)
hum.Position = teleport1B.Position + Vector3.new(0,2,0)
wait(5)
canTeleport= true -- Sets the "Debounce" to true so it can teleport
end
end
end
yea instead of getting humanoidrootpart, try getting player model
local teleport1B = script.Parent.Parent.TeleportReceiver
local canTeleport = true
function TeleportA(part)
if part then
if canTeleport then
canTeleport = false
part.Character:MoveTo(Teleport1B.Position + Vector3.new(0,2,0))
wait(5)
canTeleport= true -- Sets the "Debounce" to true so it can teleport
end
end
end
script.Parent.Triggered:Connect(TeleportA)
I Always using MoveTo() instead of position or cframe. or you can use :SetPrimaryPartCFrame()
This Should Work Perfectly
Thank you, this works!! Quick question though, why did you set the Vector3.new position to 0,2,0? Previously it would move it to 0,5,0 and it worked good. (This teleports it but it puts on on top of the part (It may just be the way I designed the part that the player teleports to though)
You Cant use Vector3.New On A .CFrame Value
And I Change It From 5 to 2, So The Player Dont Teleport Too High From The Part. Preventing Hackers or low fps gamers