Will this work? If not what should I do?
local v = script.Parent.Parent
local PlaceID = v.Portal.ID.Value
function onTouched(hit)
character = hit.Parent
if character then
game:GetService("TeleportService"):Teleport(PlaceID, character)
end
end
script.Parent.Touched:connect(onTouched)
Here is my other script but if you can fix it then that would be great.
TeleDebounce1 = false
local LPlayer = game.Players.LocalPlayer
local BitsFrame = LPlayer.PlayerGui["_gui"]
local character = LPlayer.Character
for i,v in pairs(workspace.Portals:GetChildren()) do
v.Portal.Touched:connect(function(Who)
if Who.Parent:findFirstChild("Humanoid") and not TeleDebounce2 then
TeleDebounce2 = true
BitsFrame.Parent.TeleGui.Visible = true
--Begin Functions
local title = v.Portal.Title
local img = v.Portal.Img
local a = BitsFrame.Parent.TeleGui
a:TweenPosition(UDim2.new(0.5, -150, 0.5, -200), "Out", "Quad", 0.5)
a.Title.Text = title.Value
a.Img.Image = img.Value
BitsFrame.Parent.menuMusic:Pause()
BitsFrame.Parent.teleGui:Play()
wait(0.5)
BitsFrame.Parent.menuMusic:Play()
a:TweenPosition(UDim2.new(0, -300, 0.5, -200), "Out", "Quad", 0.5)
game:GetService("TeleportService"):Teleport(v.Portal.ID.Value, character)
--Close Gui
wait(0.5)
BitsFrame.Parent.TeleGui.Visible = false
TeleDebounce2 = false
end
end)
end

4 comments
Why have this as a local script, instead of a normal script? In any case that you need it to be local, use the Touched event on the local player's torso, then check if that is a portal.
Well I want this to be inside my framework so I don't have an overload of portals with the exact same script.
So make a variable called Torso? local Torso = charactar.Torso
Then just loop through each portal and have one script. But if you need it to be local then instead of looping through all the portals and adding an event to them, don't. Just add the connection to the Torso.