But I want to add more Scrolls and not only 2.
You need to tell us what this code is supposed to do to the tool, as well as tell us what the tool is, otherwise we donât really know what youâre trying to do altogether.
It will make one scroll become invisible if you click it once (activate it) and not all at the same time and then if you click it again, one scroll will become invisible.
Is there a certain order that the scrolls become invisible? Does one new scroll become invisible each time you click?
Try this, activated only returns true or false, and you can only have one else statement so you have to create a variable (activateCount) that increases each time itâs been activated and use elseif to check it.
See this for more info Control Structures | Roblox Creator Documentation
local tool = script.Parent
local activateCount = 0
tool.Activated:Connect(function()
activateCount += 1
if activateCount == 1 then
tool.Handle.Scroll1A.Transparency = 1
tool.Handle.Scroll1B.Transparency = 1
elseif activateCount == 2 then
tool.Handle.Scroll2A.Transparency = 1
tool.Handle.Scroll2B.Transparency = 1
elseif activateCount == 3 then
tool.Handle.Scroll3A.Transparency = 1
tool.Handle.Scroll3B.Transparency = 1
elseif activateCount == 4 then
tool.Handle.Scroll4A.Transparency = 1
tool.Handle.Scroll4B.Transparency = 1
elseif activateCount == 5 then
tool.Handle.Scroll5A.Transparency = 1
tool.Handle.Scroll5B.Transparency = 1
elseif activateCount == 6 then
tool.Handle.Scroll6A.Transparency = 1
tool.Handle.Scroll6B.Transparency = 1
end
end)
Oh, we just posted the same thing. I will delete my post
Oh Iâm sorry I was editing and I didnât see your post
It seems like it starts from Scroll 6.
Are the scrolls placed in the correct order?
Nevermind, they work great. Thanks to you and oopacity for solving it.
local tool = script.Parent
local activateCount = 0
local Activations = {
[1] = {tool.Handle.Scroll1A, tool.Handle.Scroll1B},
[2] = {tool.Handle.Scroll2A, tool.Handle.Scroll2B},
[3] = {tool.Handle.Scroll3A, tool.Handle.Scroll3B},
[4] = {tool.Handle.Scroll4A, tool.Handle.Scroll4B},
[5] = {tool.Handle.Scroll5A, tool.Handle.Scroll5B},
[6] = {tool.Handle.Scroll6A, tool.Handle.Scroll6B},
}
tool.Activated:Connect(function()
if activateCount > #Activations then
return;
end
activateCount += 1
if Activations[activateCount] then
Activations[Activations][1].Transparency = 1
Activations[Activations][2].Transparency = 1
end
end)
This should work was well, I think itâs better than use 5 elseifâs.
local tool = script.Parent
local handle = tool.Handle
local activateCount = 0
tool.Activated:Connect(function()
activateCount += 1
for _, Child in ipairs(handle:GetChildren()) do
if Child.Name:match("^Scroll"..activateCount) then
Child.Transparency = 1
end
end
end)