there is a Unselect function, I just didn’t put it in this ex, but its running even tho its not supposed to
local Button = script.parent
local Name = script.parent.Name
local COOLDOWN = false
local Selected = script.parent.Selected
local function Select()
if Selected.Value ~= nil then
Unselect() -- still runs event tho Selected is nil or nothing
end
if Selected.Value ~= Name then
Button.TextTransparency = 0
Selected.Value = Name
end
end
Button.MouseButton1Up:Connect(function()
if COOLDOWN == false then
Select()
wait(0.3)
COOLDOWN = true
end
end)
Your script is kinda wrong about the 1st 5 lines. Try using Parent instead of parent
local Button = script.Parent
local Name = script.Parent.Name
local COOLDOWN = false
local Selected = script.Parent.Selected
local function Select()
if Selected.Value ~= nil then
Unselect() -- still runs event tho Selected is nil or nothing
end
if Selected.Value ~= Name then
Button.TextTransparency = 0
Selected.Value = Name
end
end
Button.MouseButton1Up:Connect(function()
if COOLDOWN == false then
Select()
wait(0.3)
COOLDOWN = true
end
end)
Is selected a StringValue? The type doesn’t matter actually, but no ??Value instance can have the value nil. What do you store there? Literally the string "nothing"? Or the integer 0 if it’s an IntValue?
No that’s not what I meant. I meant StringValues can’t hold the value nil (AFAIK), not that variables previously holding a string can’t be assigned nil afterwards.