i want to have a teleporter to a different game that requires a badge for the teleporter to work for the player.
im a terrible scripter and usualy just search up how to do these types of things.
I have looked every where on the dev forum even on google and youtube but it looks like nobody has talked about how to do this yet.
this is the current script im using for the normal teleporters.
local gameID = #######
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TeleportService:Teleport(gameID, player)
end
end
script.Parent.Touched:connect(onTouched)
local gameID = "ID_HERE"
local TeleportService = game:GetService("TeleportService")
local badges = game:GetService("BadgeService")
local userHasBadge = badges.UserHasBadgeAsync
local badgeId = 2125638306
function onTouched(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local success, result = pcall(userHasBadge, badges, player.UserId, badgeId)
if success then
TeleportService:Teleport(gameID, player)
end
end
end
end
script.Parent.Touched:connect(onTouched)
local gameID = "ID_HERE"
local TeleportService = game:GetService("TeleportService")
local badges = game:GetService("BadgeService")
local userHasBadge = badges.UserHasBadgeAsync
local badgeId = 2125638306
function onTouched(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local success, result = pcall(userHasBadge, badges, player.UserId, badgeId)
if success then
if result then
TeleportService:Teleport(gameID, player)
end
end
end
end
end
script.Parent.Touched:connect(onTouched)