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

Save/Load script with FilteringEneabled active don't work. why?

Asked by 6 years ago

I have a save/load script, the problem i have is, if i have FE disabled the script works, but when i actívate it to make local parts it don't work. The script is inside the server script service and is a script not a local script. Someone know how to fix this?

wait()

local player = script.Parent.Parent.Parent.Parent

local savebutton = script.Parent.Save
local loadbutton = script.Parent.Load

local notifysave = savebutton.Notify
local notifyload = loadbutton.Notify

local saveDB = false
savebutton.MouseButton1Up:connect(function()
    if saveDB then return end
    saveDB = true
    notifysave.Text = "  Saving..."
    notifysave.Visible = true
    local cpnum = player:FindFirstChild("CheckPointNumber")
    if cpnum ~= nil then
        if cpnum.Value == 0 or cpnum.Value == 1 then
            notifysave.Text = "  Refused save request"
        else
            player:WaitForDataReady()
            player:SaveNumber("CheckPoint", cpnum.Value)
            wait(1)
            notifysave.Text = "  Saved Data!"
        end
    else
        notifysave.Text = "  Stat unavailable!"
    end
    wait(1.5)
    notifysave.Text = ""
    notifysave.Visible = false
    saveDB = false
end)

local loadDB = false
loadbutton.MouseButton1Up:connect(function()
    if loadDB then return end
    loadDB = true
    notifyload.Text = "  Loading..."
    notifyload.Visible = true
    local cpnum = player:FindFirstChild("CheckPointNumber")
    if cpnum ~= nil then
        player:WaitForDataReady()
        local cpnumber = player:LoadNumber("CheckPoint")
        if cpnumber == nil or cpnumber == 0 then
            wait(1)
            notifyload.Text = "  Could not load data!"
        else
            cpnum.Value = cpnumber
            wait(1)
            notifyload.Text = "  Loaded Data!"
        end
    else
        notifyload.Text = "  Stat unavailable!"
    end
    wait(1.5)
    notifyload.Text = ""
    notifyload.Visible = false
    loadDB = false
end)
0
You should be using a data store and a remote event to save the data on the server not in the local script, this would be very hacky if they could save their data in a local script. User#5423 17 — 6y
0
Also WaitForDataReady is deprecated I'm pretty sure. PyccknnXakep 1225 — 6y
0
You are using data persistence. Please change it to datastores as they are better in almost any regard and are the prefered method. lukeb50 631 — 6y
0
Thx i changed to datastore now it works, i'm new to scripting ALVAROPING1 2 — 6y

Answer this question