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

I have this data store script that i think should work but it doesn't?. please help

I know the first part works but its the part where it saves when you click the gui that doesn't.

local DataStore = game:GetService("DataStoreService")
local DS1 = DataStore:GetDataStore("ExampleDataStore")



game.Players.PlayerAdded:connect(function(player)
	local leader = Instance.new("Folder",player)
	leader.Name = "leaderstats"
	local Bricks = Instance.new("IntValue",leader)
	Bricks.Name = "bricks"
	Bricks.Value = DS1:GetAsync(player.UserId) or 0
	DS1:SetAsync(player.UserId, Bricks.Value)
	local SaveGUI = game.StarterGui.SaveGUI.SaveGUIFrame.SaveGUIButton


game.Players.PlayerRemoving:connect(function(player)
	print("Saveing Data")
	DS1:SetAsync(player.UserId, player.leaderstats.Bricks.Value)
	print(player.Name.."'s Data of"..player.leaderstats.Bricks.Value.." "..player.leaderstats.Bricks.Name.."has been saved!")

end)

this is what doesn't work



SaveGUI.MouseButton1Click:connect(function()
	DS1:SetAsync(player.UserId, player.leaderstats.Bricks.Value)
	print("Saved!")
end)

end)

4 comments

0

Why do you have more than one 'end)'?

0

The last end id for the first function line 6

0

the last end is*

0

Take the PlayerRemoving out of the PlayerAdded function. It won't fix your problem but that is retarded.

1 answer

✓ Accepted answer

You can't access data stores with local scripts. Make it like fire a remote event on the gui to save.

6 comments

0

Be sure to accept answer!

0

its not a local script

0

Well, you can't do MouseButton1Click in a non-local script. Correct me if I'm wrong.

0

Accept answer if this helped. I don't like leeches. Report anymore issues.

0

thx

0

np

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