See, I am making a website type of game, it is replicating your browser and you can play the game like your on your browser.
For example: You can create a new tab.
But, after deleting that new tab, it DOES NOT go to the last one that was created. – 1st thing I need to do.
That first thing I need to do is tricky.
for that one thing, I created something like:
Tab.NumberRank.Value = Numbers + 1 -- See, if this was 6 and the list of tabs changed then it would go to number 5.
-- Basically descending order.
But, I had some issues with this when I was trying to do it.
Like, After adding a new tab and then deleting a new tab, it would select nothing.
But I have no proof of this, so I can’t show you, but I can show you current things.
https://gyazo.com/8f911047f5caf7b3a66694b4e3473df6
In this gif, you can see that I removed the code that allowed it to go to the last number after the one above was destroyed, and so now it does not select anything after deleting a tab.
Things that works:
Home button - works.
searchbar - works(i only make one website at a time so that it creates the tab with the desired domain name and image. EX: type in google.com and press enter it creates a tab called google.com and changes its contents.)
What I managed to achieve.
It no longer selects 2 tabs after creating a new one(The one currently selected and the new one that was created.)
Code:
local WebGET =game.ReplicatedStorage.WebsiteGet
local TB = script.Parent.TaskBar
local TestTab = TB.TestTab
local Start = false
local Numbers = 0
local SearchBar = TB.WebOutline.WebBar
SearchBar.Text = 'Tutorial.org'
local ActiveTabs = {}
-- Functions
function CreateTab(Name,Icon)
local Tab = TestTab:Clone()
Tab.Name = Name
if Icon == nil then
Tab.TabName.Text = Name
Tab.Visible = true
Tab.Parent = TB.ListOfTabs
Tab.Opened.Value = true
local Add = TB.ListOfTabs.AddTab
Add.Parent = TB
Add.Parent = TB.ListOfTabs
Tab.NumberRank.Value = Numbers + 1
Numbers = Tab.NumberRank.Value
table.insert(ActiveTabs,Tab.Name)
else
if Icon ~= nil then
Tab.TabName.Text = Name
Tab.Visible = true
Tab.Opened.Value = true
Tab.Parent = TB.ListOfTabs
Tab.Load.Visible = false
Tab.IconOfTab.Image = Icon
Tab.IconOfTab.Visible = true
Tab.IconOfTab.ImageTransparency = 0
table.insert(ActiveTabs,Tab.Name)
local Add = TB.ListOfTabs.AddTab
Add.Parent = TB
Add.Parent = TB.ListOfTabs
Tab.NumberRank.Value = Numbers + 1
Numbers = Tab.NumberRank.Value
end
end
return Tab
end
function DestroyTab(Object)
Object.NumberRank.Value = Numbers - 1
Numbers = Numbers - 1
Object:Destroy()
table.remove(ActiveTabs,ActiveTabs[Object.Name])
end
function SelectTab(Object)
Object.BackgroundTransparency = 0
TB.WebOutline.WebBar.Text = Object.Contents.Value
end
function SetAwayTab(Object)
Object.BackgroundTransparency = 1
end
function Back()
for i,v in pairs(TB.ListOfTabs:GetChildren()) do
if v.Name == 'AddTab' then
-- nothing
elseif v.Name == 'UIListLayout' then
-- nothing
else
if v.BackgroundTransparency == 0 then
-- tuff
end
end
end
end
function CreateTab(Name,Icon)
local Tab = TestTab:Clone()
Tab.Name = Name
if Icon == nil then
Tab.TabName.Text = Name
Tab.Visible = true
Tab.Parent = TB.ListOfTabs
Tab.Opened.Value = true
local Add = TB.ListOfTabs.AddTab
Add.Parent = TB
Add.Parent = TB.ListOfTabs
Tab.NumberRank.Value = Numbers + 1
Numbers = Tab.NumberRank.Value
table.insert(ActiveTabs,Tab.Name)
else
if Icon ~= nil then
Tab.TabName.Text = Name
Tab.Visible = true
Tab.Opened.Value = true
Tab.Parent = TB.ListOfTabs
Tab.Load.Visible = false
Tab.IconOfTab.Image = Icon
Tab.IconOfTab.Visible = true
Tab.IconOfTab.ImageTransparency = 0
table.insert(ActiveTabs,Tab.Name)
local Add = TB.ListOfTabs.AddTab
Add.Parent = TB
Add.Parent = TB.ListOfTabs
Tab.NumberRank.Value = Numbers + 1
Numbers = Tab.NumberRank.Value
end
end
return Tab
end
-- End of Functions
-- Connect Events
TB.ListOfTabs.AddTab.MouseButton1Click:Connect(function()
CreateTab('New Tab')
end)
TB.ListOfTabs.ChildAdded:Connect(function(object)
if object.Name == 'UIListLayout' then
-- nothing.
elseif object.Name == 'AddTab' then
-- nothing.
else
for i,v in pairs(TB.ListOfTabs:GetChildren()) do
for i,z in pairs(ActiveTabs) do
if object.Name == z then
if v.Name == 'UIListLayout' then
-- nothing
else
if v.Name == 'AddTab' then
-- nothing
else
if v.Opened.Value == true then
v.Opened.Value = false
SetAwayTab(v)
SelectTab(object)
object.Opened.Value = true
else
SelectTab(object)
object.Opened.Value = false
end
end
end
end
if v.Name == 'UIListLayout' then
-- nothing
else
if v.Name == 'AddTab' then
-- nothing
else
SetAwayTab(v)
SelectTab(object)
end
end
end
end
end
if object.Name == 'UIListLayout' then
-- nothing.
else
if object.Name == 'AddTab' then
-- nothing.
else
local bing = object.MouseButton1Click:connect(function()
for i,v in pairs(TB.ListOfTabs:GetChildren()) do
if v.Name == 'AddTab' then
-- nothing
else
if v.Name == 'UIListLayout' then
-- nothing
else
SetAwayTab(v)
SelectTab(object)
end
end
end
end)
local zing = object.Close.MouseButton1Click:connect(function()
DestroyTab(object)
end)
if object == nil then
bing:Disconnect()
zing:Disconnect()
end
end
end
end)
TB.LeftA.MouseButton1Click:Connect(function()
warn('Not implemented yet.')
end)
TB.RightA.MouseButton1Click:Connect(function()
warn('Not implemented yet.')
end)
TB.HomeButton.MouseButton1Click:Connect(function()
if TB.ListOfTabs:FindFirstChild('Home') then
DestroyTab(TB.ListOfTabs:FindFirstChild('Home'))
CreateTab('Home','rbxassetid://4846958865')
else
CreateTab('Home','rbxassetid://4846958865')
end
for i,v in pairs(TB.ListOfTabs:GetChildren()) do
if v.Name == 'AddTab' then
-- nothing
elseif v.Name == 'UIListLayout' then
-- nothing
else
if v.Name == 'Home' then
SelectTab(v)
elseif v.Name ~= 'Home' then
SetAwayTab(v)
end
end
end
end)
TB.Refresh.MouseButton1Click:Connect(function()
warn('Not implemented yet.')
end)
function Apply()
for i,v in pairs(TB.ListOfTabs:GetChildren()) do
if v.Name == 'AddTab' then
-- nothing
elseif v.Name == 'UIListLayout' then
-- nothing
else
if v.BackgroundTransparency == 0 then
v.Contents.Value = TB.WebOutline.WebBar.Text
end
end
end
end
TB.WebOutline.WebBar.FocusLost:Connect(function()
if TB.WebOutline.WebBar.Text == 'youtube.com' then
for i,v in pairs(TB.ListOfTabs:GetChildren()) do
if v.Name == 'AddTab' then
-- nothing
elseif v.Name == 'UIListLayout' then
-- nothing
else
if v.BackgroundTransparency == 0 then
CreateTab('Youtube','rbxassetid://4849838156')
v.Contents.Value = ''
TB.ListOfTabs:FindFirstChild('Youtube').Contents.Value = 'https://www.youtube.com/'
Apply()
end
end
end
elseif TB.WebOutline.WebBar.Text == 'google.com' then
for i,v in pairs(TB.ListOfTabs:GetChildren()) do
if v.Name == 'AddTab' then
-- nothing
elseif v.Name == 'UIListLayout' then
-- nothing
else
if v.BackgroundTransparency == 0 then
CreateTab('Google','rbxassetid://4863583258')
v.Contents.Value = ''
TB.ListOfTabs:FindFirstChild('Google').Contents.Value = 'https://www.google.com/'
Apply()
end
end
end
end
Apply()
end)
-- End of Connect Events
CreateTab('Start','rbxassetid://4848497568')
CreateTab('Unknown')
Suggestions and tips will be nice.
Also, I did want to make it so after you hover on one of the tabs, it will change it’s color to white and after you stop, it will return back to normal but after i tried it, it did not go back to normal, so I gave up on that until on a later notice.