I have this game I'm trying to remake famous and this save script isn't working?It doesn't save data
Game: http://www.roblox.com/Galactic-Front-ALPHA-TELEPORT-GLITCH-PATCHED-place?id=178549718
Not Working Script:
01 | debounce = false |
02 | function Save() |
03 | if debounce = = false then |
04 | debounce = true |
05 | player = game.Players.LocalPlayer |
06 | script.Parent.Text = "Saving..." |
07 | player:WaitForDataReady() |
08 | player:SaveNumber( "Credit" , player.Credit.Value) |
09 | inv = player:FindFirstChild( "Inventory" ) |
10 | for saveinv = 1 , 8 do |
11 | if inv~ = nil then |
12 | saveslot = inv:FindFirstChild( "Slot" ..saveinv) |
13 | if saveslot~ = nil then |
14 | player:SaveString(( "Slot" ..saveinv), saveslot.Value) |
15 | end |
1) I recommend using Data Stores, Data Persistence is outdated, here's the Data Store wiki page 2) You can't access Data Persistence or Data Stores through LocalScripts, you need a normal script.
Here's your revamped script:
01 | local player = script.Parent.Parent.Parent.Parent.Parent.Parent --assuming this button is in a TextButton, in a ScreenGui, this is how to find player |
02 | local creditSaves = game:GetService( "DataStoreService" ):GetDataStore( "creditSaves" ) |
03 | local invSaves = game:GetService( "DataStoreService" ):GetDataStore( "invSaves" ) |
04 | local credits = player.Credit.Value |
05 | local inv = player:FindFirstChild( "Inventory" ) |
06 | local deb = false |
07 | script.Parent.MouseButton 1 Click:connect( function () |
08 | if not deb and player:WaitForDataReady() then |
09 | deb = true |
10 | script.Parent.Text = "Saving..." |
11 | creditSaves:SetAsync(player.Name.. " credits" , credits) |
12 | for saveInv = 1 , 8 do |
13 | if inv then |
14 | saveSlot = inv:FindFirstChild( "Slot" ..saveInv) |
15 | if saveSlot then |
That should work.