for _, Button in ipairs(script.Parent:GetChildren()) do
if Button:IsA("ImageButton") then
Button.MouseButton1Up:Connect(function()
if Button:GetAttribute("Equipped") == false then
game.TweenService:Create(Button, TweenInfo.new(0.5, Enum.EasingStyle.Elastic), {Size = UDim2.new(0, 87, 0, 87)}):Play()
Button.Outline.Transparency = 0
Button:SetAttribute("Equipped", true)
for _, Buttons in ipairs(script.Parent:GetChildren()) do
if Buttons:IsA("ImageButton") then
game.TweenService:Create(Buttons, TweenInfo.new(0.5, Enum.EasingStyle.Elastic), {Size = UDim2.new(0, 80, 0, 80)}):Play()
Buttons.Outline.Transparency = 0.5
Buttons:SetAttribute("Equipped", false)
end
end
else
game.TweenService:Create(Button, TweenInfo.new(0.5, Enum.EasingStyle.Elastic), {Size = UDim2.new(0, 80, 0, 80)}):Play()
Button.Outline.Transparency = 0.5
Button:SetAttribute("Equipped", false)
end
end)
end
end
Try prints before each if check to see what the variable is beforehand. If the Output print isn’t what you expect to see then look at the section of code that sets that variable.
For example:
for _, Button in ipairs(script.Parent:GetChildren()) do
print("Button's name = ", Button.Name)
if Button:IsA("ImageButton") then
Button.MouseButton1Up:Connect(function()
print("Equipped = ", Button:GetAttribute("Equipped"))
if Button:GetAttribute("Equipped") == false then
-- etc.
Printing it at after the “for _,” prints each button’s name twice, and printing it “if GetAttribute == Value” print’s the button’s name that’s being pressed. When testing I was looking at the atttribute inside the buttons themselves in the my player’s playergui and nothing happened.
I found the issue. The script is printing that the “Equipped” attribute is true, when it the workspace it shows as false. I’ve tried it as both a LocalScript and Script on Client and nothing seems to work.
I put a print statement after the :SetAttribute() and the script seems to think it actually changed the attribute when in reality it didn’t.
When the client changes something, it won’t appear on the server. You have to connect a RemoteEvent or (recommended) UnreliableRemoteEvent and fire that to change the attribute.
And the rest of the script should still run even though the attribute isn’t changing, since there are no errors, but the rest of the script doesn’t run…