Hey developers,
I’ve been working on a script that when you touch a part it teleports you to another part. The script used to work, but now it doesn’t anymore which I’m assuming is due to roblox updates. Could anybody help fix this script?
function Touch(hit)
if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true
local Pos = script.Parent.Parent:findFirstChild(Teleport)
hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end
script.Parent.Touched:connect(Touch)
local players = game:GetService("Players")
local Pos = script.Parent.Parent:FindFirstChild("Teleport")
local debounceDictionary = {}
script.Parent.Baseplate.Touched:Connect(function(hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
if players:GetPlayerFromCharacter(hit.Parent) then
if debounceTable[hit.Parent.Name] == nil then
debounceTable[hit.Parent.Name] = true
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
Humanoid:MoveTo(Pos.Position)
wait(0.5) --you can see this as the debounce time..
debounceTable[hit.Parent.Name] = nil
end
end
end
end)