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

SetASync is not a valid member of GlobalDataStore?

Asked by
3wdo 198
5 years ago
Edited 5 years ago

i was making a daily reward system from the youtuber alvinblox but i got an error saying "SetASync is not a valid member of GlobalDataStore" line 62

    local DataStore = game:GetService("DataStoreService"):GetDataStore("DailyRewards")



local hourWait = 24



local possibleRewards = {10,15,10,10,5,5,5,5,5,1000000,300,500,1000,100,600,5,5,75,25,80,100,1000000,5000000}





game.Players.PlayerAdded:Connect(function(player)

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

leaderstats.Parent = player

local cash = Instance.new("IntValue")

cash.Name = "Cash"

cash.Parent = leaderstats

local timeNow = os.time()

local data

pcall(function()

data = DataStore:GetASync(player.UserId.."-dailyReward")

print("Getting Data")

end)

if data ~= nil then

--Returning player

local TimeSinceLastClaim = timeNow - data

print("Time Since Last Claim "..TimeSinceLastClaim)

if (TimeSinceLastClaim / 3600) >= hourWait then

-- They are eligible for a reward

local reward = possibleRewards[math.random(1,#possibleRewards)]

game.ReplicatedStorage.ShowDailyReward:FireClient(player,hourWait,reward)

local connection

connection = game.ReplicatedStorage.ClaimReward.OnServerEvent:Connect(function(triggeringPlayer)

if triggeringPlayer == player then

print("Reward Claimed")

player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + reward

DataStore:SetASync(player.UserId.."-dailyReward",os.time())

connection:Disconnect()

end

end)

else

print("Player Is Not Eligible Right Now")

end

else

--New player

print("New player")

local reward = possibleRewards[math.random(1,#possibleRewards)]

game.ReplicatedStorage.ShowDailyReward:FireClient(player,hourWait,reward)

local connection

connection = game.ReplicatedStorage.ClaimReward.OnServerEvent:Connect(function(triggeringPlayer)

if triggeringPlayer == player then

print("Reward Claimed")

player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + reward

DataStore:SetASync(player.UserId.."-dailyReward",os.time())

connection:Disconnect()

end

end)

end

end)





--[[game.Players.PlayerRemoving:Connect(function(player)

local data

pcall(function(player)

data = DataStore:GetASync(player.UserId.."-dailyReward")

print("Getting The Data")

end)

if data == nil then

--New player

pcall(function()

local TimeVal = os.time()

DataStore:SetASync(player.UserId.."-dailyReward")

end)

print("Saved Because Your A New Player")

end

end)--]]

line 67 cuz the thing is weird for me its, the code aint going in this correctly

1
This is why you don't watch AlvinBlox. DeceptiveCaster 3761 — 5y
0
its Async not ASync mattchew1010 396 — 5y
0
ikr Clasterboy 72 — 5y
0
ok 3wdo 198 — 5y
0
change SetASync to SetAsync AnonymousDeveloper13 22 — 5y

1 answer

Log in to vote
0
Answered by
3wdo 198
4 years ago

i fixed it a long time ago but i forgot to answer my own question lol all i had to do was enable studio access to API services

Ad

Answer this question