Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make an unlock teleport?

When a player touch an brick they will be teleport to an other place but if they touch it without having the badges that are needed their will show up an gui.

They need the found example 3 badges until then can teleport to it. When they don't found the correct onces they get an gui on their screen.

On an brick(part) when they touches it.

Full script:

game:GetService('TeleportService').CustomizedTeleportUI = true
local BadgeService = game:GetService("BadgeService")
local badges  = {229929415, 229929797, 229929912}
local debounce = false

function getPlayer(Part)
	local Humanoid = Part.Parent:FindFirstChild('Humanoid')
	if (Humanoid ~= nil) then
		local Character = Humanoid.Parent
		if (Character ~= nil) then
			return game:GetService('Players'):GetPlayerFromCharacter(Character)		
		end
	end
end

function onTouch(part)
	if BadgeService:UserHasBadge(player.UserId, badges) then
		function _sendPlayerToLobby(player)
		local playerIdentity = player.Name .. '(' .. player.userId .. ')'
		game:GetService('TeleportService'):Teleport(195733678, player)	
	end
		local sendPlayerToLobby = debounce(_sendPlayerToLobby)
 			function onTouch(Source)
				local player = getPlayer(Source)	
				if player then
				if player.userId > 0 then	
				sendPlayerToLobby(player)
				end		
			end	
		end
	end
elseif script.Parent.NeededGUI:clone().Parent = player.PlayerGui then
	end
end

Parts of script:

The badges:

local badges  = {229929415, 229929797, 229929912}

Send player too other place and if player doesn't have the badges gui comes up:

if BadgeService:UserHasBadge(player.UserId, badges) then
		function _sendPlayerToLobby(player)
		local playerIdentity = player.Name .. '(' .. player.userId .. ')'
		game:GetService('TeleportService'):Teleport(195733678, player)	
	end
		local sendPlayerToLobby = debounce(_sendPlayerToLobby)
 			function onTouch(Source)
				local player = getPlayer(Source)	
				if player then
				if player.userId > 0 then	
				sendPlayerToLobby(player)
				end		
			end	
		end
	end
elseif script.Parent.NeededGUI:clone().Parent = player.PlayerGui then
	end
end

I did mess it up I think. Does someone know how I can fix this. Thank you :)

minetrackmania

1 comment

1

Fixed me response.

1 answer

✓ Accepted answer

The only thing wrong you did with this script is, You forgot to add a for loop otherwise your script should work fine!

Now lets get to fixing that script shall we? now I might add some edits of my own if you don't mind.

game:GetService('TeleportService').CustomizedTeleportUI = true
local BadgeService = game:GetService("BadgeService")
local badges  = {229929415, 229929797, 229929912}
local debounce = false
-- adding for loop here so you can use it Throughout the script.
for _,v in pairs(badges)do -- putting the rest of the script within the for loop otherwise It would have ended before you could ever have used it.
function getPlayer(Part)
    local Humanoid = Part.Parent:FindFirstChild('Humanoid')
    if (Humanoid ~= nil) then
        local Character = Humanoid.Parent
        if (Character ~= nil) then
            return game:GetService('Players'):GetPlayerFromCharacter(Character)     
        end
    end
end

function onTouch(part)
    if BadgeService:UserHasBadge(player.UserId, badges) then
        function _sendPlayerToLobby(player)
        local playerIdentity = player.Name .. '(' .. player.userId .. ')'
        game:GetService('TeleportService'):Teleport(195733678, player)  
    end
        local sendPlayerToLobby = debounce(_sendPlayerToLobby)
            function onTouch(Source)
                local player = getPlayer(Source)    
                if player then
                if player.userId > 0 then   
                sendPlayerToLobby(player)
                end     
            end 
        end
    end
elseif script.Parent.NeededGUI:clone().Parent = player.PlayerGui then
    end
end
end

So what did we do? we added a for loop now we need to make it to where you can use it! we must use v for badges now!

game:GetService('TeleportService').CustomizedTeleportUI = true
local BadgeService = game:GetService("BadgeService")
local badges  = {229929415, 229929797, 229929912}
local debounce = false
-- adding for loop here so you can use it Throughout the script.
for _,v in pairs(badges)do -- putting the rest of the script within the for loop otherwise It would have ended before you could ever have used it.
function getPlayer(Part)
    local Humanoid = Part.Parent:FindFirstChild('Humanoid')
    if (Humanoid ~= nil) then
        local Character = Humanoid.Parent
        if (Character ~= nil) then
            return game:GetService('Players'):GetPlayerFromCharacter(Character)     
        end
    end
end

function onTouch(part)
    if BadgeService:UserHasBadge(player.UserId, v) then  -- added v here instead of badges because now it will use all of the badges.
        function _sendPlayerToLobby(player)
        local playerIdentity = player.Name .. '(' .. player.userId .. ')'
        game:GetService('TeleportService'):Teleport(195733678, player)  
    end
        local sendPlayerToLobby = debounce(_sendPlayerToLobby)
            function onTouch(Source)
                local player = getPlayer(Source)    
                if player then
                if player.userId > 0 then   
                sendPlayerToLobby(player)
                end     
            end 
        end
    end
x = script.Parent.NeededGUI:Clone()
elseif x.Parent = player.PlayerGui then
    end
end
end

the script SHOULD work, doesn't mean it will, I might have used the wrong kind of for loop. I am not sure how to make the other kind of for loop unfortunately so I can't re-do the script just-incase this doesn't work for you.

2 comments

0

Line 33 broken

0

Cannot test out yet but for now I already do accept your answer :)

This discussion is preserved as it was. New answers, comments, and votes are closed.