Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

SetASync is not a valid member of GlobalDataStore?

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

5 comments

1

This is why you don't watch AlvinBlox.

0

its Async not ASync

0

ikr

0

ok

0

change SetASync to SetAsync

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.