Remote Function
Everything have been fixed without any error. But then problems is the currency doesnt add into players currency
--Client
local TextBox = script.Parent.TextBox
local Button = script.Parent.RedeemButton
Button.MouseButton1Click:Connect(function()
local Code = TextBox.Text
local redeem = game.ReplicatedStorage.RemoteFuntion:InvokeServer(Code)
if redeem == true then
TextBox.Text = " "
TextBox.PlaceholderText = "Success"
wait(0.5)
TextBox.PlaceholderText = "Text Here"
else
TextBox.Text = " "
TextBox.PlaceholderText = "Invalid"
wait(0.5)
TextBox.PlaceholderText = "Text Here"
end
end)
Why it doesnt work?
--Server
local DataService = game:GetService("DataStoreService")
local ListCode = {
TestCode = {"Money", 2500},
Code2020 = {"Money", 2020}
}
game.ReplicatedStorage.RedeemCode.OnServerInvoke = function(plr, Code)
local players = game.Players:FindFirstChild(plr.Name)
local CodeStore = DataService:GetDataStore("CodeStore" .. Code)
local plrRedeem = CodeStore:GetAsync(players.UserId)
if ListCode[Code] and not plrRedeem then
local statsName = ListCode[Code][1]
local amtValue = ListCode[Code][2]
local statsValue = players.leaderstats[statsName].Value
statsValue = statsValue + amtValue
CodeStore:SetAsync(players.UserId, true)
return true
else
return false
end
end

1 comment
It is giving out the information weather it true or false but the problem is, it didnt add my currency. Why?