Hello there, I am trying to make a thing that teleports everybody that is trying to teleport to a place to that place when an event is triggered. If you click a button, it teleports you to a part this script is inside of that is transparent and has CanCollide off but has a touched event inside it that make a value inside the player true. My problem is that the thing that teleports people only happens once, and it can't happen again. I'm pretty sure the problem is that it's a changed event inside a touched event function, and needs to be outside of it. I need to retrieve the data from the touched event to the changed event.
local TeleportService = game:GetService("TeleportService")
local GameID = 5948456863
local TeleportBoolian = game.ReplicatedStorage.TeleportBoolian
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local CTB = player:FindFirstChild("CanTeleportBoolian")
if CTB then
print("CTB HERE")
CTB.Value = true
print("true")
--where the code used to be
end
end
end)
--where the code is now
TeleportBoolian.Changed:Connect(function()
print("Teleporting Phase 1")
if TeleportBoolian and CTB.Value == true then
print("Teleporting Phase 2")
TeleportService:Teleport(GameID, player)
end
end)

3 comments
im gonna try this out and see if it works
sorry, but it's still running into the same problem, ill try something i think is gonna work tommorow
Think i found the problem its when you change the global TeleportBoolian Value it doesnt get replicated on players. so i've added a way to change it from this server side script. (Note: i've changed the Gameid to 1 so i dont teleport to your game unexpectally lol), Updatd my answer