Need help with platform attribution system

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Im trying to make a system that brings trains on a certain platform depending on the others occupancy

  2. What is the issue? Include screenshots / videos if possible!
    the switch doesnt activate and no errors appear

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    my problem is unique i think
    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 occupancy = script.Parent.Occupancy
local aparts = script.Parent.AParts:GetChildren()
local bparts = script.Parent.BParts:GetChildren()
local cparts = script.Parent.CParts: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 = 0.6
	for i,v in pairs(cparts) do
		v.CanCollide = false
		v.Transparency = 0.6
	       end
		end
	end
end

function Switch2()
	for i,v in pairs(bparts) do
		v.CanCollide = false
		v.Transparency = 0.6
		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 = 0.6
			end
		end
	end
end

function Switch3()
	for i,v in pairs(aparts) do
		v.CanCollide = false
		v.Transparency = 0.6
		for i,v in pairs(bparts) do
			v.CanCollide = false
			v.Transparency = 0.6
			for i,v in pairs(cparts) do
				v.CanCollide = true
				v.Transparency = 0
			end
		end
	end
end



function AttrQuai()
	if occupancy.VoieAOcc == false and occupancy.VoieBOcc == false and occupancy.VoieCOcc == false then
		Switch1()	
	else if	occupancy.VoieAOcc == true and occupancy.VoieBOcc == false and occupancy.VoieCOcc == false then
		Switch2()
	else if occupancy.VoieAOcc == true and occupancy.VoieBOcc == true and occupancy.VoieCOcc == false then	
		Switch3()	
			end	
		end
	end
end

s1.Touched:connect(AttrQuai)
s2.Touched:connect(Switch1)
s3.Touched:connect(Switch2)
s4.Touched:connect(Switch3)

image

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.

bumping the post as i still need help

i just forgot to add .Value to my booolleans

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.