So I have a daily rewards gui and when I click the claim it should give rewards but the script is functioning properly? Any clues?
local folder = script.Settings local rewardDebounce = folder.RewardTime.Value local ls = folder.LeaderStatsEnabled local lsName = ls:WaitForChild("Name") local lsValue = ls:WaitForChild("Reward") function reward(p) if ls == true then local find = p:FindFirstChild("leaderstats") if find then local val = find:FindFirstChild(lsName.Value) if type(val) == "number" then val.Value = val.Value + lsValue.Value end end end end local ds = game:GetService("DataStoreService"):GetDataStore("DailyReward") function ending(text) print(text) local e = string.sub(text,string.len(text)-3) if tonumber(lsValue.Value) ~= 1 and e == "(%.+)e" then text = text.. "s" end return text end function give(key,p) repeat wait() until p.Character wait(2) local gui = script.DailyRewardGui:Clone() gui.Parent = p.PlayerGui if ls.Value == true then gui.main.text.Text = lsValue.Value.. " " ..ending(lsName.Value).."!" else gui.main.text:Destroy() gui.main.title.Text = "You got your daily reward!" gui.main.title.FontSize = Enum.FontSize.Size24 gui.main.title.Size = UDim2.new(1,0,0.7,0) end repeat wait() until gui.done.Value == true print("Giving reward to " ..p.Name) ds:SetAsync(key,os.time()) reward(p) end function setup(key) local t local success,msg = pcall(function() t = ds:GetAsync(key) end) if not success then warn("New player..") t = os.time() - rewardDebounce elseif type(t) ~= "number" then warn("Error, resetting..") t = os.time() - rewardDebounce else warn("DataStore retrieval successful (daily reward script)") end return t end function checkReady(key,t,p) local newTime = os.time() local secs = newTime - t if secs >= rewardDebounce then print(p.Name.. " has an unclaimed reward!") give(key,p) else print(p.Name.. " has already had a reward today!") end end game.Players.PlayerAdded:connect(function(p) local key = "user_" ..p.UserId local lastPlayed = setup(key) print(lastPlayed.. " vs. " ..os.time()) checkReady(key,lastPlayed,p) end)