Would this affect performance?

I’m making a car shop gui and I have a section where you select the brands to view. When you click a button it tweens any gui out of the screen that’s not the name of the frame but I have the local scripts in each button cause they are in separate frames.

image

this is how the scripts look like

local ShowNissan = script.Parent.Parent.Parent.Parent.Nissan
local ShowToyota = script.Parent.Parent.Parent.Parent.Toyota


script.Parent.MouseButton1Click:Connect(function()    
	ShowNissan:TweenPosition(UDim2.new(0.307, 0,0.245, 0),"Out","Quint",0.5,true) -- Position to move frame/tween style
end)

script.Parent.MouseButton1Click:Connect(function()    
	ShowToyota:TweenPosition(UDim2.new(1.307, 0,0.245, 0),"Out","Quint",0.5,true) -- Position to move frame/tween style
end)

anytime I add another brand ill have to add more and i wanna know if this will have a effect on the performance of the game to players?

Doesn’t look like it should affect performance in a bad way. I’m not sure though, I’m not the best scripter.

alright, and viewports wouldn’t cause a problem you don’t think? cause im gonna be making the cars spinning

I don’t believe viewpoints should cause any problems unless a glitch happens.

1 Like

Why do you make a connection for each brand? Couldn’t you tween them in one connection?

idk easier for me ig cause im gonna be making a frame change colour when selected and not selected or at least try (lol)

local ShowNissan = script.Parent.Parent.Parent.Parent.Nissan
local NissCol = script.Parent.Parent.Parent.NissanToggle
local ShowToyota = script.Parent.Parent.Parent.Parent.Toyota
local ToyCol= script.Parent.Parent.Parent.ToyotaToggle

script.Parent.MouseButton1Click:Connect(function()
NissCol.BackgroundColor3 = Color3.fromRGB(85, 255, 0)
ShowNissan:TweenPosition(UDim2.new(0.307, 0,0.245, 0),"Out","Quint",0.5,true) -- Position to move frame/tween style

end)


script.Parent.MouseButton1Click:Connect(function()
	NissCol.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	ShowToyota:TweenPosition(UDim2.new(1.307, 0,0.245, 0),"Out","Quint",0.5,true) -- Position to move frame/tween style
end)


unless there is a simpler way

update it does work yay

Have the same script point towards all of the UI instances and handle each with a few functions (since they are all handled similarly anyway).