I am trying to make a script where when you touch a part it will make a gui visible then gives all the players in the server a badge and teleports to a new private server. And yes I have canTouch on. If you could solve this problem I will be very greatful!
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 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)
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)
print("touchedWorked")
--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)
to even see if it works.
Also don’t forget to change your if to if humanoid and debounce then:D