local train1 = script.Parent.Parent.Train_1:GetDescendants()
local occupiedvalue = script.Parent.occupiedValue
function touch(traincheck)
if traincheck.Parent.Name == “Train_1” then
print(“Train1 has been stopped at station”)
script.Parent.CanCollide = true
traincheck.Parent.Anchored = true
for _,v in pairs(train1) do
if v:IsA(“BasePart”) then
v.Anchored = false
end
end
elseif occupiedvalue == 1 then
script.Parent.CanCollide = false
print(“Train has departed from station”)
for _,v in pairs(train1) do
if v:IsA(“BasePart”) then
v.Anchored = false
end
occupiedvalue = 0
end
end
end
Parent.Touched:connect(touch)
What I want in this script is for when a model with the name “Train_1” touches it, the brick will turn collide on and the mdoel will anchor. However, it doesn’t work at all. Can someone help me please?