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

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

Asked by
abrobot 44
6 years ago

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)
0
Why do you have more than one 'end)'? obcdino 113 — 6y
0
The last end id for the first function line 6 abrobot 44 — 6y
0
the last end is* abrobot 44 — 6y
0
Take the PlayerRemoving out of the PlayerAdded function. It won't fix your problem but that is retarded. PolyyDev 214 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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

0
Be sure to accept answer! DaWarTekWizard 169 — 6y
0
its not a local script abrobot 44 — 6y
0
Well, you can't do MouseButton1Click in a non-local script. Correct me if I'm wrong. DaWarTekWizard 169 — 6y
0
Accept answer if this helped. I don't like leeches. Report anymore issues. DaWarTekWizard 169 — 6y
View all comments (2 more)
0
thx abrobot 44 — 6y
0
np DaWarTekWizard 169 — 6y
Ad

Answer this question