You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Im making a train switch scripts that loops through parts in a model to change their transparency and
cancollide values -
What is the issue? Include screenshots / videos if possible!
whenever the platform attribution function starts there is a huge lag spikes and the script times out
surely due to the models having more than 50 parts
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--Points layout instructions--
-- Place the S2 on the track with the A parts, and the S1 on the track with the B parts.
-- Each route with a set of points is automatically decided.
local s1 = script.Parent.S1
local s2 = script.Parent.S2
local s3 = script.Parent.S3
local s4 = script.Parent.S4
local s5 = script.Parent.S5
local s6 = script.Parent.S6
local s7 = script.Parent.S7
local transparency = 0.1
local occupancy = script.Parent.Occupancy
local aparts = script.Parent.AParts:GetChildren()
local bparts = script.Parent.BParts:GetChildren()
local cparts = script.Parent.CParts:GetChildren()
local dparts = script.Parent.DParts:GetChildren()
local eparts = script.Parent.EParts:GetChildren()
local fparts = script.Parent.FParts:GetChildren()
local gparts = script.Parent.GParts:GetChildren()
local hparts = script.Parent.HParts:GetChildren()
local iparts = script.Parent.IParts:GetChildren()
--//General functions
function Switch1()
for i,v in pairs(aparts) do
v.CanCollide = true
v.Transparency = 0
for i,v in pairs(bparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(cparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(dparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(eparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(fparts) do
v.CanCollide = false
v.Transparency = transparency
end
end
end
end
end
end
end
task.wait(2)
function Switch2()
for i,v in pairs(aparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(bparts) do
v.CanCollide = true
v.Transparency = 0
for i,v in pairs(cparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(dparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(eparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(fparts) do
v.CanCollide = false
v.Transparency = transparency
end
end
end
end
end
end
end
task.wait(2)
function Switch3()
for i,v in pairs(aparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(bparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(cparts) do
v.CanCollide = true
v.Transparency = 0
for i,v in pairs(dparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(eparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(fparts) do
v.CanCollide = false
v.Transparency = transparency
end
end
end
end
end
end
end
task.wait(2)
function Switch4()
for i,v in pairs(aparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(bparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(cparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(dparts) do
v.CanCollide = true
v.Transparency = 0
for i,v in pairs(eparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(fparts) do
v.CanCollide = false
v.Transparency = transparency
end
end
end
end
end
end
end
task.wait(2)
function Switch5()
for i,v in pairs(aparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(bparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(cparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(dparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(eparts) do
v.CanCollide = true
v.Transparency = 0
for i,v in pairs(fparts) do
v.CanCollide = false
v.Transparency = transparency
end
end
end
end
end
end
end
task.wait(2)
function Switch6()
for i,v in pairs(aparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(bparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(cparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(dparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(eparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(fparts) do
v.CanCollide = true
v.Transparency = 0
end
end
end
end
end
end
end
task.wait(2)
function Switch7()
for i,v in pairs(gparts) do
v.CanCollide = true
v.Transparency = 0
for i,v in pairs(hparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(iparts) do
v.CanCollide = false
v.Transparency = transparency
end
end
end
end
task.wait(2)
function Switch8()
for i,v in pairs(gparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(hparts) do
v.CanCollide = true
v.Transparency = 0
for i,v in pairs(iparts) do
v.CanCollide = true
v.Transparency = transparency
end
end
end
end
task.wait(2)
function Switch9()
for i,v in pairs(gparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(hparts) do
v.CanCollide = false
v.Transparency = transparency
for i,v in pairs(iparts) do
v.CanCollide = true
v.Transparency = 0
end
end
end
end
task.wait(2)
function AttrQuai()
if occupancy.VoieAOcc.Value == false and occupancy.VoieBOcc.Value == false and occupancy.VoieCOcc.Value == false and occupancy.VoieDOcc.Value == false and occupancy.VoieEOcc.Value == false and occupancy.VoieFOcc.Value == false then
Switch1()
print("Switch 1")
else if occupancy.VoieAOcc.Value == true and occupancy.VoieBOcc.Value == false and occupancy.VoieCOcc.Value == false and occupancy.VoieDOcc.Value == false and occupancy.VoieEOcc.Value == false and occupancy.VoieFOcc.Value == false then
Switch2()
Switch9()
print("Switch 2")
else if occupancy.VoieAOcc.Value == true and occupancy.VoieBOcc.Value == true and occupancy.VoieCOcc.Value == false and occupancy.VoieDOcc.Value == false and occupancy.VoieEOcc.Value == false and occupancy.VoieFOcc.Value == false then
Switch3()
Switch7()
print("Switch 3")
else if occupancy.VoieAOcc.Value == true and occupancy.VoieBOcc.Value == true and occupancy.VoieCOcc.Value == true and occupancy.VoieDOcc.Value == false and occupancy.VoieEOcc.Value == false and occupancy.VoieFOcc.Value == false then
Switch4()
Switch9()
else if occupancy.VoieAOcc.Value == true and occupancy.VoieBOcc.Value == true and occupancy.VoieCOcc.Value == true and occupancy.VoieDOcc.Value == true and occupancy.VoieEOcc.Value == false and occupancy.VoieFOcc.Value == false then
Switch5()
Switch7()
else if occupancy.VoieAOcc.Value == true and occupancy.VoieBOcc.Value == true and occupancy.VoieCOcc.Value == true and occupancy.VoieDOcc.Value == true and occupancy.VoieEOcc.Value == true and occupancy.VoieFOcc.Value == false then
Switch9()
task.wait(2)
Switch6()
else
print("Attr échoué")
end
end
end
end
end
end
end
task.wait(2)
print("Aiguille script a fini d'etre initialisee")
s1.Touched:connect(AttrQuai)
s2.Touched:connect(Switch1)
s3.Touched:connect(Switch2)
s4.Touched:connect(Switch3)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.