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

why does script load my data a few times and then just doesnt?

Asked by
MHaven1 159
4 years ago
--Local Script
local Debounce = false
script.Parent.MouseButton1Click:Connect(function()
    if Debounce == false then
        Debounce = true
        local LoadEvent = game.ReplicatedStorage.Events.Player.LoadData
        LoadEvent:FireServer(script.Parent, script.Parent.Check)
        repeat wait()
        until script.Parent.Check.Value == true
        if script.Parent.Check.Value == true then
            script.Parent.Parent.Parent:Destroy()
        end
        wait(1)
        Debounce = false
    end
end)
-- ServerScript
local MoneyDataStore = game:GetService("DataStoreService"):GetDataStore("money1")
LoadData.OnServerEvent:Connect(function(Player, Button, Check)
        local GetMoney
        local success1, failed1 = pcall(function()
            GetMoney = MoneyDataStore:GetAsync(NewPlayer.userId..":Money")
        end)
        if success1 then
            local Text2 = Player.Name.."'s Money Data Found"
            for A = 1,#Text2 do
                Button.Text = string.sub(Player.Name.."'s Money Data Found.", 1, A)
                wait(0.05)
            end
            wait(0.25)
            for B = 1,#"Loading Money Data..." do
                Button.Text = string.sub("Loading Money Data...", 1, B)
                wait(0.05)
            end
            wait(0.25)
            for C = 1,#"Money Loaded" do
                Button.Text = string.sub("Money Loaded", 1, C)
                wait(0.05)
            end
            Money.Value = GetMoney
        else
            for C = 1,#"There Was An Error Getting You Money Data." do
                Button.Text = string.sub("There Was An Error Getting You Money Data.", 1, C)
                wait(0.05)
            end
            Money.Value = 0
            warn(failed1)
        end
        wait(0.25)
        Check.Value = true
    end)

the script loads the data a few times but then it just does not get the data it just resets it to 0 i dont get any errors what so ever and after it resets the data i rejoin my data is always 0 it and if i give my self money again it will load it a few times then just reset the data again.

0
Debug. Put some prints. Check if the server event gets called, and put a print with information after every if and else to see what your code does. Please provide this information and then we can help. Nowaha 459 — 4y
0
the messages i put in those works like the gui changes the text and everything from money data found etc to money loaded. if those are working then i guess the script is running right? MHaven1 159 — 4y
0
Unfortunately, I haven't tried the datastore yet, can't help you.??? Eternalove_fan32 188 — 4y
0
np MHaven1 159 — 4y
0
sad Alpha_Imperial 5 — 4y

Answer this question