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

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

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.

5 comments

0

What error do you get? You might need to add .Value to Alpha.Reward

0

Thanks.

0

And yes, you would need to use DataStores

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

0

Ok, thanks!

1 answer

✓ Accepted answer

Line 10.

player.leaderstats.Credits.Value + codes.Alpha.Reward.Value

1 comment

0

Thanks, I theCJarmy7 told me, and I realized it.

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