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

How would I make it so that the code cannot be used again if you leave then rejoin?

Asked by 5 years ago
Edited 5 years ago

I don't want players to be able to enter the code again if they leave then rejoin. Would I need to use datastores?

local codes = script.Parent.Parent.Codes -- location of the codes

script.Parent.MouseButton1Down:Connect(function()
    if script.Parent.Parent.codeBox.Text == "Alpha" then
        if codes.Alpha.Value == true then
            script.Parent.Parent.codeBox.Text = "Already Redeemed!"
        end
        if codes.Alpha.Value == false then
            codes.Alpha.Value = true
            game.Players.LocalPlayer.leaderstats.Credits.Value = game.Players.LocalPlayer.leaderstats.Credits.Value + codes.Alpha.Reward.Value -- change Credits to your currency's name and the number to how much you want to award them for entering the code.
            script.Parent.Parent.codeBox.Text = "Redeemed!"
        end
    end
end)

Also my game is Filtering Enabled.

0
What error do you get? You might need to add `.Value` to Alpha.Reward theCJarmy7 1293 — 5y
0
Thanks. K1ng_Phant0m 13 — 5y
0
And yes, you would need to use DataStores theCJarmy7 1293 — 5y
0
Also, since you have fe, you would need to use a RemoteEvent to ask the server to change the money and handle the dataStore stuff theCJarmy7 1293 — 5y
0
Ok, thanks! K1ng_Phant0m 13 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Line 10.

player.leaderstats.Credits.Value + codes.Alpha.Reward.Value
0
Thanks, I theCJarmy7 told me, and I realized it. K1ng_Phant0m 13 — 5y
Ad

Answer this question