So basically I am making a shop system that consists of items, when a player enables one item I want them to obtain it but when it enables another item then it obtains 2 items at once, how would I go about making the player enable one item and if they want to enable another item then the item they had will disappear and they will obtain that one item.
The best solution here would be to have a BoolValue somewhere in PlayerGui and Check if it’s true,if true then do the code for it else just add 1st effect
EDIT:
if (AlreadyEquipped == true) then
--Code
else
--OtherCode
end
Oh right so you mean like create a boolean variable for every item and if the player enables one item then set the boolean of that item to true and the rest of the booleans to false, right?
Oh and I know how to set bool variables, thank you.
Alright so something like this would be good enough:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local RedSword = PlayerGui:WaitForChild("Folder"):WaitForChild("RedSwordBool")
RedSwordEnableButton.MouseButton1Click:Connect(function()
if RedSword == false then
RedSword = true
---- the rest of the boolean values will be set to false
end)
Alright, so after me sorting out the code because I messed it up, it came to the conclusion that it works but one more thing, how do we save it using a datastore, maybe I could create a table that is contained with those boolean values and save it like that?