|
| 12 May 2014 05:38 PM |
game:GetService('TeleportService').CustomizedTeleportUI = true ds = game:GetService("DataStoreService"):GetGlobalDataStore() local Trigger = script.Parent -- debouncer that prevents multiple trigger events by the player who is standing nearby. 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:SetAsync(playerKey, playerData) end if playerData and playerData.personalPlaceId then game:GetService('TeleportService'):Teleport(playerData.personalPlaceId, player) end end local sendPlayerToBuildZone = debounce(_sendPlayerToBuildZone) -- Touch event function function onTouch(Source) local player = getPlayer(Source) if player then if player.userId > 0 then sendPlayerToBuildZone(player) end end end Trigger.Touched:connect(onTouch) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ If you look at the line newPlaceId = game:CreatePlace('Building zone for ' .. playerIdentity, 92697995), you will notice that this lobby uses the place with ID 92697995 to create personal player zones. Is that correct, though? |
|
|
| Report Abuse |
|