What this is supposed to do is whenever a player touches a block, it creates a new place with the specified ID and teleports them to it. It creates a new place every time (so that way it's the most updated version at all times). However, it's not functioning -- nothing shows up whenever I touch the block it's in, nor do I teleport. Here's the code:
game:GetService('TeleportService').CustomizedTeleportUI = true
ds = game:GetService("DataStoreService"):GetDataStore("places")
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)
local newPlaceId = game:GetService("AssetService"):CreatePlaceAsync('Burned Into My Memory Lite for ' .. playerIdentity, 180024170, 'You have played this place!')
playerData = {
personalPlaceId = newPlaceId
}
ds:SetAsync(playerKey, playerData)
game:GetService('TeleportService'):Teleport(playerData.personalPlaceId, player.Character)
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
script.Parent.Touched:connect(onTouch)
It's a modified version of the code on the wiki for doing this. However, that code didn't allow places to be updated, so I couldn't use it exactly.
Thank you for reading, and I hope to find a swift answer!
