I’ve created a waterslide and I need the player to go down it, so I created this velocity script that makes each part of the slide have a certain amount of velocity
local slideparts = script.Parent:GetChildren()
for i = 1, #slideparts do
local slidepart = slideparts[i]
local union = slidepart:FindFirstChild("Tube")
wait(0.1)
union.Velocity = Vector3.new(0, 0, 80)
print("eat") --Debugging purposes
end
The error means there is no object inside slidepart called “Tube”. Can you confirm that there is indeed a “Tube” part in every one of those tube slides?
GetChildren only gets one layer of instances. You need to use GetDescendants()
So GetChildren only sees, Slide, Tube Slide, etc… and not Model, union, tube.
local slideparts = script.Parent:GetDescendants()
for i = 1, #slideparts do
if(slideparts[i].Name == "Tube")then
slideparts[i].Velocity = Vector3.new(0, 0, 80)
print("eat")
end
end
Your script is taking the Slide script as one of the objects.
Then you are telling it to find “Tube” inside of it.
Then, without checking whether or not it actually found a “Tube”, you are asking it to set it’s velocity.
You should either check that the object it’s searching is a model (not a script) or better yet add a if statement after the wait(0.1) verifying that union exists.