|
| 23 Jul 2015 11:39 AM |
So I'm trying to create a place for the player to have, their own little place. But I get no errors, and it doesn't create the place. This is a LocalScript in a TextButton.
--8BitDeveloping
game:GetService('TeleportService').CustomizedTeleportUI = true ds = game:GetService("DataStoreService"):GetGlobalDataStore()
function debounce(func) local isRunning = false return function(...) if not isRunning then isRunning = true func(...) isRunning = false end end end
function _sendPlayerToScareZone(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('Frenzy: Eternity map 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(_sendPlayerToScareZone) -- Click event function function click(Source) local player = game.Players.LocalPlayer if player then if player.userId > 0 then _sendPlayerToScareZone(player) end end end
script.Parent.MouseButton1Click:connect(click)
i really really really wanna run over youuu |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 11:44 AM |
Actually, I'm getting the "DataStore cannot be accessed" error from this line:
ds = game:GetService("DataStoreService"):GetGlobalDataStore()
help
i really really really wanna run over youuu |
|
|
| Report Abuse |
|
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
| |
|
|
| 23 Jul 2015 11:46 AM |
| DataStore only works in server scripts. |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 11:48 AM |
So how would I get the datastore from a server script and insert it into the localscript? Global variable? or..
i really really really wanna run over youuu |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 11:51 AM |
| Use a remote function to interact with the datastore on the server. |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 12:20 PM |
Thank you! Got it working.
i really really really wanna run over youuu |
|
|
| Report Abuse |
|
|