Hey I was wondering is it possible to turn this from onTouch to onClick GUI instead? ScreenGUI>Textbutton>LocalScript
How would I go about doing this? please help!
Dynamic place creation and saving
The script I want to know how to change to onClick rather than onTouch
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)

3 comments
I tried that out filled in the rest of the functions and everything, the localscript is inside textbutton itself button = script.parent
This shows in server log "Datastore can't be accessed from client"
Oh whoops, that is because DataStores can only be accessed from the sever. You could use a RemoteEvent to invoke the serever when a player clicks.