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

Twitter Gui with Data Store Service!?

Asked by 5 years ago

Hey i need help please.

local Players = game:GetService("Players")
local DataStore = game:GetService("DataStoreService")
local ds2 = DataStore:GetDataStore("PointsSaveSystem")

Players.PlayerAdded:Connect(function(plr)
    local Redeeemed = Instance.new("BoolValue",plr)
    Redeeemed.Name = "Used"
    Redeeemed.Value = ds2:GetAsync(plr.UserId) or false
    ds2:SetAsync(plr.UserId, Redeeemed.Value)

    local leaderstats = Instance.new("Configuration", plr)
    leaderstats.Name = "leaderstats"

    local Coins = Instance.new("IntValue", leaderstats)
    Coins.Name = "Coins"
    Coins.Value = ds2:GetAsync(plr.UserId) or 0
    ds2:SetAsync(plr.UserId, Coins.Value)

    Redeeemed.Changed:Connect(function()
        ds2:SetAsync(plr.UserId, Redeeemed.Value, Coins.Value)
    end)

    Coins.Changed:Connect(function()
        ds2:SetAsync(plr.UserId, Redeeemed.Value, Coins.Value)
    end)
end)

Players.PlayerRemoving:Connect(function(plr)
    local Used = plr:FindFirstChild("Used")
    local Coins = plr:FindFirstChild("leaderstats"):WaitForChild("Coins")
    ds2:SetAsync(plr.UserId, Used.Value, Coins.Value)
end)
0
Errors? green271 635 — 5y
0
there isn't error. FrezeTagger 75 — 5y
0
You shouldn't use WaitForChild on PlayerRemoving lol. Also, The parent argument to Instance.new is deprecated, assign the parent as last property. User#19524 175 — 5y

Answer this question