So im making a shop and i want to make it so they can’t equip two titles. So like when they equip 2 the first one will not same unequip and would say equip. So like they can only equip one title.
Heres an image
the long way:
make it so like if you have one title equip, it makes all the other title be unequipped ( through a script )
the short way:
there is no short way
how would i do it in a script is my is question
An easy way to do it is put bool values named “Equipped” in the buttons, and then when you equip them it sets the bool value to true, and the other way around.
Before you go doing this, please show me the script.
which script?
The button script_________________________
ok here
local cost = 5
local titleVal = Instance.new("StringValue")
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
if player:WaitForChild("Check")[tostring(script.Parent.Parent.Name)].Value == true then
script.Parent.Text = "Equip"
end
script.Parent.MouseButton1Down:Connect(function()
if player.Check[tostring(script.Parent.Parent.Name)].Value == true then
if script.Parent.Text == "Equip" then
wait(1)
script.Parent.Text = "Equipped"
player.Character:WaitForChild("Head").NameTag.LowerText.Text = script.Parent.Parent.Name
player.Character:WaitForChild("Head").NameTag.LowerText.TextColor3 = Color3.new(script.Parent.Parent.BackgroundColor3)
player.Character:WaitForChild("Head").NameTag.LowerText.LocalScript.Disabled = true
player.EquippedTitle.Value = script.parent.Parent.Name
wait()
script.Parent.Text = "Unequip"
else
if script.Parent.Text == "Unequip" then
wait()
player.Character:WaitForChild("Head").NameTag.LowerText.Text = "Guest"
player.Character:WaitForChild("Head").NameTag.LowerText.TextColor3 = Color3.new(218, 218, 218)
player.Character:WaitForChild("Head").NameTag.LowerText.LocalScript.Disabled = true
player.EquippedTitle.Value = ""
script.Parent.Text = "Equip"
end
end
end
end)
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.Wins.Value >= cost then
if player:WaitForChild("Check")[tostring(script.Parent.Parent.Name)].Value == false then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value - cost
wait()
script.Parent.Text = "Bought"
titleVal.Name = script.Parent.Parent.Name
wait()
script.Parent.Text = "Equip"
print("You bought this title")
player.Check[tostring(script.Parent.Parent.Name)].Value = true
end end end)
In a few minutes I will be back to help
alrighty
Alright. So create a bool value named “Equipped” in all of the buttons
Alright i added the values into the buttons
and make it so if you equip one title, change equipped to true for that title, and equipped to false for all other titles
local Buttons = {
{
["Instance"] = script.Parent.A,
["Equipped"] = false,
["EquipFunction"] = function(_self)
print("Equipping A")
_self.Equipped = true
end,
["UnequipFunction"] = function(_self)
print("Unequipping A")
_self.Equipped = false
end
},
{
["Instance"] = script.Parent.B,
["Equipped"] = false,
["EquipFunction"] = function(_self)
print("Equipping B")
_self.Equipped = true
end,
["UnequipFunction"] = function(_self)
print("Unequipping B")
_self.Equipped = false
end
}
}
local function Unequip(Button)
if Button.Equipped then
Button.UnequipFunction(Button)
end
return
end
local function Equip(Button)
if not Button.Equipped then
Button.EquipFunction(Button)
end
return
end
for Index, Button in pairs(Buttons) do
Button.Instance.MouseButton1Click:Connect(function()
if Button.Instance.Text == "Equip" then
Equip(Button)
Button.Instance.Text = "Unequip"
for _, _Button in pairs(Buttons) do
if _Button ~= Button then
_Button.Instance.Text = "Equip"
Unequip(_Button)
end
end
else
Button.Instance.Text = "Equip"
Unequip(Button)
end
end)
end
Buttons.rbxl (25.8 KB)
where would i put that script?
Under the same parent as your buttons, download the place file I attached to the reply
You don't have to write a whole new script
local cost = 5
local titleVal = Instance.new("StringValue")
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
if player:WaitForChild("Check")[tostring(script.Parent.Parent.Name)].Value == true then
script.Parent.Text = "Equip"
end
script.Parent.MouseButton1Down:Connect(function()
if player.Check[tostring(script.Parent.Parent.Name)].Value == true then
if script.Parent.Text == "Equip" then
wait(1)
script.Parent.Text = "Equipped"
player.Character:WaitForChild("Head").NameTag.LowerText.Text = script.Parent.Parent.Name
player.Character:WaitForChild("Head").NameTag.LowerText.TextColor3 = Color3.new(script.Parent.Parent.BackgroundColor3)
player.Character:WaitForChild("Head").NameTag.LowerText.LocalScript.Disabled = true
player.EquippedTitle.Value = script.parent.Parent.Name
wait()
for i, text in pairs(script.Parent.Parent.Parent:GetChildren()) do local first = text:FindFirstChildOfClass("TextLabel") if first then first:FindFirstChildOfClass("TextButton").Text = "Equip" end
script.Parent.Text = "Unequip"
end
else
if script.Parent.Text == "Unequip" then
wait()
player.Character:WaitForChild("Head").NameTag.LowerText.Text = "Guest"
player.Character:WaitForChild("Head").NameTag.LowerText.TextColor3 = Color3.new(218, 218, 218)
player.Character:WaitForChild("Head").NameTag.LowerText.LocalScript.Disabled = true
player.EquippedTitle.Value = ""
script.Parent.Text = "Equip"
end end
end
end)
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.Wins.Value >= cost then
if player:WaitForChild("Check")[tostring(script.Parent.Parent.Name)].Value == false then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value - cost
wait()
script.Parent.Text = "Bought"
titleVal.Name = script.Parent.Parent.Name
wait()
script.Parent.Text = "Equip"
print("You bought this title")
player.Check[tostring(script.Parent.Parent.Name)].Value = true
end
end
end)
it still lets me equip everything
This should be the final fix
local cost = 5
local titleVal = Instance.new("StringValue")
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
if player:WaitForChild("Check")[tostring(script.Parent.Parent.Name)].Value == true then
script.Parent.Text = "Equip"
end
script.Parent.MouseButton1Down:Connect(function()
if player.Check[tostring(script.Parent.Parent.Name)].Value == true then
if script.Parent.Text == "Equip" then
wait(1)
script.Parent.Text = "Equipped"
player.Character:WaitForChild("Head").NameTag.LowerText.Text = script.Parent.Parent.Name
player.Character:WaitForChild("Head").NameTag.LowerText.TextColor3 = Color3.new(script.Parent.Parent.BackgroundColor3)
player.Character:WaitForChild("Head").NameTag.LowerText.LocalScript.Disabled = true
player.EquippedTitle.Value = script.parent.Parent.Name
wait()
for i, text in pairs(script.Parent.Parent.Parent:GetChildren()) do local first = text:FindFirstChildOfClass("TextButton") if first then if player:WaitForChild("Check")[tostring(first.Parent.Parent.Name)].Value == true then first.Text = "Equip" end
script.Parent.Text = "Unequip"
end end
else
if script.Parent.Text == "Unequip" then
wait()
player.Character:WaitForChild("Head").NameTag.LowerText.Text = "Guest"
player.Character:WaitForChild("Head").NameTag.LowerText.TextColor3 = Color3.new(218, 218, 218)
player.Character:WaitForChild("Head").NameTag.LowerText.LocalScript.Disabled = true
player.EquippedTitle.Value = ""
script.Parent.Text = "Equip"
end end
end
end)
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.Wins.Value >= cost then
if player:WaitForChild("Check")[tostring(script.Parent.Parent.Name)].Value == false then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value - cost
wait()
script.Parent.Text = "Bought"
titleVal.Name = script.Parent.Parent.Name
wait()
script.Parent.Text = "Equip"
print("You bought this title")
player.Check[tostring(script.Parent.Parent.Name)].Value = true
end
end
end)
Where is the script located???