Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- updated 09-10-2014
- script for a lobby teleportation pad
- programmed by NewtPewt
- ]]--
- game:getservice("teleportservice").customizedteleportgui = true
- ds = game:getservice("datastoreservice"):getglobaldatastore()
- local trigger = script.parent
- function debounce(func)
- local isrunning = false
- return function(...)
- if not isrunning then
- isrunning = true
- func(...)
- isrunning = false
- end
- end
- end
- 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 _sendplayertobuildzone(player)
- local playeridentity = player.name .. "(" .. player.userid .. ")"
- local playerkey = "player_" .. player.userid
- local playerdata = ds:getasync(playerkey)
- if playerdata then
- if playerdata.personalplaceid <= 0 then
- playerdata = nil
- end
- end
- if not playerdata then
- newplaceid = game:getservice("assetservice"):createplaceasync("Building zone for " .. playerIdentity, 92697995)
- playerdata = {
- personalplaceid = newplaceid
- }
- ds:getasync(playerkey, playerdata)
- end
- if playerdata and playerdata.personalplaceid then
- game:getservice("teleportservice"):teleport(playerdata.personalplaceid, player)
- end
- end
- local sendplayertobuildzone = debounce(_sendplayertobuildzone)
- function ontouch(source)
- local player = getplayer(source)
- if player then
- if player.userid > 0 then
- sendplayertobuildzone(player)
- end
- end
- end
- trigger.touched:connect(ontouch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement