Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't this script work?

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:

debounce=false
function Save()
	if debounce==false then
		debounce=true 
		player=game.Players.LocalPlayer
		script.Parent.Text="Saving..."
		player:WaitForDataReady()
		player:SaveNumber("Credit", player.Credit.Value)
		inv=player:FindFirstChild("Inventory")
		for saveinv=1,8 do
			if inv~=nil then
				saveslot=inv:FindFirstChild("Slot"..saveinv)
				if saveslot~=nil then
					player:SaveString(("Slot"..saveinv), saveslot.Value)
				end
			end
		end
		wait(2)
		script.Parent.Text="Save"
		debounce=false
	end
end


script.Parent.MouseButton1Down:connect(Save)

3 comments

0

Please put your code into the Code Block. It will really help me answer your question.

0

There

0

Thanks.

1 answer

  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:

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
local creditSaves = game:GetService("DataStoreService"):GetDataStore("creditSaves")
local invSaves = game:GetService("DataStoreService"):GetDataStore("invSaves")
local credits = player.Credit.Value
local inv = player:FindFirstChild("Inventory")
local deb = false
script.Parent.MouseButton1Click:connect(function()
if not deb and player:WaitForDataReady() then
deb = true
script.Parent.Text = "Saving..."
creditSaves:SetAsync(player.Name.." credits", credits)
for saveInv = 1, 8 do
if inv then
saveSlot = inv:FindFirstChild("Slot"..saveInv)
if saveSlot then
invSaves:SetAsync(player.Name.." inventory", saveInv)
end
end
end
script.Parent.Text = "Save"
end
end)

That should work.

20 comments

0

Alright, Testing it.

0

Not to be rude or anything, But could you make the script for me?

0

Lol ok.

0

xP

0

But my game is diffrent, Go play it and see...The save has to save GUI weapons/guns/helmets and stuff

0

Ok. I'll check it out after school.

0

Okay.

0

If you like that answer, please mark it as accepted. It helps me out.

0

I put that script in a regular script and doesn't work, Do I put n a local script?

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.

0

Its a TextButton in a frame and that frame is in another frame, THEN comes the screen GUI

0

Wait, so it's TextButton>Frame>Frame>ScreenGui?

0

Mhm

0

Ok.

0

So........

0

Sorry, I've been working on other projects. I'll start on yours as soon as I get home from school.

0

Okay, :P

0

Its been a day, Done yet? :P

0

Not yet

0

Its been soooooooo long, Done yet? :L

This discussion is preserved as it was. New answers, comments, and votes are closed.