Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't this script work?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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:

01debounce=false
02function 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
View all 25 lines...
0
Please put your code into the Code Block. It will really help me answer your question. bobafett3544 198 — 10y
0
There epicfatcookie 0 — 10y
0
Thanks. bobafett3544 198 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

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:

01local player = script.Parent.Parent.Parent.Parent.Parent.Parent --assuming this button is in a TextButton, in a ScreenGui, this is how to find player
02local creditSaves = game:GetService("DataStoreService"):GetDataStore("creditSaves")
03local invSaves = game:GetService("DataStoreService"):GetDataStore("invSaves")
04local credits = player.Credit.Value
05local inv = player:FindFirstChild("Inventory")
06local deb = false
07script.Parent.MouseButton1Click:connect(function()
08if not deb and player:WaitForDataReady() then
09deb = true
10script.Parent.Text = "Saving..."
11creditSaves:SetAsync(player.Name.." credits", credits)
12for saveInv = 1, 8 do
13if inv then
14saveSlot = inv:FindFirstChild("Slot"..saveInv)
15if saveSlot then
View all 22 lines...

That should work.

0
Alright, Testing it. epicfatcookie 0 — 10y
0
Not to be rude or anything, But could you make the script for me? epicfatcookie 0 — 10y
0
Lol ok. bobafett3544 198 — 10y
0
xP epicfatcookie 0 — 10y
View all comments (16 more)
0
But my game is diffrent, Go play it and see...The save has to save GUI weapons/guns/helmets and stuff epicfatcookie 0 — 10y
0
Ok. I'll check it out after school. bobafett3544 198 — 10y
0
Okay. epicfatcookie 0 — 10y
0
If you like that answer, please mark it as accepted. It helps me out. bobafett3544 198 — 10y
0
I put that script in a regular script and doesn't work, Do I put n a local script? epicfatcookie 0 — 10y
0
No, it's supposed to be in a regular script. I noted that the script was made if it were in a TextButton, in a ScreenGui, in StarterGui. Unless you didn't put it in that order, or I made a mistake, then it should work. bobafett3544 198 — 10y
0
Its a TextButton in a frame and that frame is in another frame, THEN comes the screen GUI epicfatcookie 0 — 10y
0
Wait, so it's TextButton>Frame>Frame>ScreenGui? bobafett3544 198 — 10y
0
Mhm epicfatcookie 0 — 10y
0
Ok. bobafett3544 198 — 10y
0
So........ epicfatcookie 0 — 10y
0
Sorry, I've been working on other projects. I'll start on yours as soon as I get home from school. bobafett3544 198 — 10y
0
Okay, :P epicfatcookie 0 — 10y
0
Its been a day, Done yet? :P epicfatcookie 0 — 10y
0
Not yet bobafett3544 198 — 10y
0
Its been soooooooo long, Done yet? :L epicfatcookie 0 — 10y
Ad

Answer this question