local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
--local code = TS:ReserveServer(86819814841501)
local players = Players:GetPlayers()
--local badgeID = 155440073325875
local part = script.Parent
local debounce = true
part.Touched:Connect(function(hitpart)
local humanoid = hitpart.Parent:FindFirstChild("Humanoid")
if humanoid and debounce then
debounce = false
for i, player in pairs(game.Players:GetPlayers()) do
print("do stuff", humanoid)
end
end
end)
local debounce = true
script.Parent.Touched:Connect(function(hitpart)
print("TEST")
local humanoid = hitpart.Parent:FindFirstChild("Humanoid")
if humanoid then
debounce = false
for i, player in pairs(game.Players:GetPlayers()) do
player.PlayerGui.LoadingScreen.Frame.Visible = true
game:GetService("BadgeService"):AwardBadge(player.UserId, badgeID)
wait(4)
TS:TeleportToPrivateServer(86819814841501, code, players)
end
end
end)
Thatâs because when you call the ReserveServer method it will yield(wait) for the server. if it was a game tested in an actual roblox player it would work, but teleportservice does not work in the studio.
Try this? You must play in the actual game client to be teleported.
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local code = TS:ReserveServer(86819814841501)
local badgeID = 155440073325875
local part = script.Parent
local debounce = true
part.Touched:Connect(function(hitpart)
local humanoid = hitpart.Parent:FindFirstChild("Humanoid")
local player = Players:GetPlayerFromCharacter(hitpart.Parent)
if humanoid and player and debounce then
debounce = false
local players = Players:GetPlayers()
-- loading screen? I copied this path from the original script soo you may want to confirm it lol.
for _, plr in ipairs(players) do
if plr.PlayerGui and plr.PlayerGui:FindFirstChild("LoadingScreen") then
plr.PlayerGui.LoadingScreen.Frame.Visible = true
end
end
-- give badge
for _, plr in ipairs(players) do
pcall(function()
if not BadgeService:UserHasBadgeAsync(plr.UserId, badgeID) then
BadgeService:AwardBadge(plr.UserId, badgeID)
end
end)
end
task.wait(4)
-- teleport and retry if fail
local success = false
local attempts = 0
local maxAttempts = 3
while not success and attempts < maxAttempts do
success = pcall(function()
TS:TeleportToPrivateServer(86819814841501, code, players)
end)
if not success then
attempts += 1
task.wait(1)
end
end
-- debounce reset
if not success then
for _, plr in ipairs(players) do
if plr.PlayerGui and plr.PlayerGui:FindFirstChild("LoadingScreen") then
plr.PlayerGui.LoadingScreen.Frame.Visible = false
end
end
debounce = true
end
end
end)```