This script makes a GUI label visible if the player has 0 saved under CheckpointReached and sets it to 0 if the player doesn't have any data stored. This function is called when a button is pressed to view whether they had any data saved. However it doesn't work - there are no errors though. What has gone wrong?
function onClick() --Find the Player local player = script.Parent.Parent.Parent.Parent.Parent --Find the DataStore value of CheckpointReached local DataStore = game:GetService("DataStoreService"):GetDataStore("CheckpointReached") local key = "user_" .. player.userId -- If the value is nil set it to 0 if DataStore:GetAsync(key) == nil then DataStore:SetAsync(key, 0) end --If the value is 0 then make SaveError visible if DataStore:GetAsync(key) == 0 then script.Parent.SaveError.Visible = true end end script.Parent.MouseButton1Down:connect(onClick)