I've been working on moving objects, and I wanted to know if I could anchor a car/train/bus/plane on the touch of a part? I know the script has to do with Functions, GetChildren, and more, but I couldn't figure out how to put them together into a script, can anyone help?
-- make a variable of the model myModel = game.Workspace:findFirstChild("ModelName") function onTouched(part) if part.Parent:findFirstChild("Humanoid") ~= nil then for _,item in pairs(myModel:GetChildren()) do if item:IsA("Seat") or item:IsA("Truss") or item:IsA("VehicleSeat") or item:IsA("SpawnLocation") or item:IsA("WedgePart") or item:IsA("Part") or item:IsA("BasePart") then -- i've done this 'IF' because there might be scripts. If it's a classname with no such propertie as anchored it will break the script! item.Anchored = true wait(10) item.Anchored = false end end end end script.Parent.Touched:connect(onTouched)
If doesn't work, tell me output.
Hope this helped! Thanks, marcoantoniosantos3