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

Save/load system not changing text of GUI?

Asked by 7 years ago
Edited 7 years ago

I'm trying to make a Save/load system. When I play my game and press "Save" it doesn't even change the text of the GUI, I've checked the output and it says nothing. It's not a localscript. When I play in roblox studio it changes the text.

local Debounce = false
local player = script.Parent.Parent.Parent.Parent
local Save = script.Parent.Save
local Load = script.Parent.Load

Save.MouseButton1Click:connect(function()
    if Debounce == false then
        Debounce = true
        Save.Text = "Saving..."
        player:WaitForDataReady()
        player:SaveBoolean("Sphere1",player.Sphere1.Value)
        Save.Text = "Saved!"
        wait(1)
        Save.Text = "Save"
        Debounce = false
    end
end)

Load.MouseButton1Click:connect(function()
    if Debounce == false then
        Debounce = true
        Load.Text = "Loading..."
        player:WaitForDataReady()
        player.Sphere1.Value = player:LoadBoolean("Sphere1")
        if player.LoadBoolean("Sphere1") == true then
            --has 1 sphere
        end
        Load.Text = "Loaded!"
        wait(1)
        Load.Text = "Load"
        Debounce = false
    end
end)

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

Your issue is probably that you attempt to acces the save and load button before they're replicated to the Client (The player)

To fix this simpfully add

local Save = script.Parent:WaitForChild("Save")
local Load = script.Parent:WaitForChild("Load")
Ad

Answer this question