im trying to make a script in a button gui that when i click it, it changes a value to the gui's name but right now it leaves the value to "None" in the output it prints : 1 2 and if i click again it prints 1 3 any idea whats wrong?
repeat wait(1)
player = game.Players.LocalPlayer
until player
local holding = script.Parent.Parent.Parent.Parent.HoldingItem.Value
local item = script.Parent
function OnClicked()
print("1")
if holding ~= item.Name then
print("2")
holding = item.Name
elseif holding == item.Name then
print("3")
holding = "None"
end
end
script.Parent.MouseButton1Click:Connect(OnClicked)

1 comment
In your code, holding is the value of the holding item when you first run the code. Its not the holding object itself. Try taking away the ".Value" from line 5 and changing "holding" to "holding.Value" in lines 9, 11, 12, and 14.