How to make a teleporter that gives you a badge aswell?

I followed some individual tutorials on how to make a block give a badge on click, and how to teleport it to another game on click (if it helps the game its teleporting to is not mine) but its not working, i think at some point i managed to get it to teleport me but not give the badge but i cant remember that well ive only just picked it up

i have two cripts one for each because i didnt know how to make them both work on one script (a pebble would know more about scripting than i do)

image
(bottom one is the badge giver, top is teleporter)

badge giver;

local Button = game.Workspace.CubeTP -- Change YourPartName to your part which players have to click.
local Click = Button.ClickDetector
local BadgeService = game:GetService("BadgeService")
local BadgeID = 265393458345341-- Change this ID to your Badge ID

Click.MouseClick:Connect(function(player)
	BadgeService:AwardBadge(player.UserId, BadgeID)
end)

teleporter

local Part = script.Parent

local CD = Part.ClickDetector

local GameId = 8835176616 -- You & Cube

CD.MouseClick:connect(function(Player)

	game:GetService("TeleportService"):TeleportAsync(GameId,{Player})

end)
1 Like

Im pretty sure that you cant teleport to a game thats not owned by the publisher.
(correct me if im wrong)

Oh no the teleport worked at one point as I said, its my partners game that it teleports to and the TP worked fine before i wanted to add the badge

heres something I cooked up real quick this is for server-side but I beleive it can be on local with some tweaks:

local badgeService = game:GetService("BadgeService")

script.Parent.Touched:Connect(function(otherPart)
	if game.Players:GetPlayerFromCharacter(otherPart.Parent) then
		local plr = game.Players:GetPlayerFromCharacter(otherPart.Parent)
		badgeService:AwardBadge(plr.UserId,badgeID) --change badgeID to desired value
	end
end)

(this is a touched event so you would have to change the connection of course)

if this worked please put it as the solution.

1 Like

This basically just gives the badge using the built in Function AwardBadge in BadgeService

1 Like

Wait are these two seperate scripts?

unfortunately yes they are , i wouldnt know how to combine them

Just add them together in server script

CD.MouseClick:connect(function(Player)
	game:GetService("TeleportService"):TeleportAsync(GameId,{Player})
    badgeService:AwardBadge(plr.UserId,badgeID) --change badgeID to desired value
end)