This is just a script to make curtains work. Most of it isn't really needed to know for the problem. The problem is at line 36.
----------Variables------------------
top = script.Parent
opened = top:WaitForChild("Opened")
closed = top:WaitForChild("Closed")
event = top:WaitForChild("String")
action = false
debounce = false
listenTo = opened.Changed:connect(function() end)
listenTo:disconnect()
switch = top:WaitForChild("Switch")
curtainScript = switch:WaitForChild("Action")
currentColor = switch.BrickColor
clickedColor = BrickColor.new("Really red")
----------Variables for curtain Setup------------------------
parts = top:WaitForChild("CurtainParts")
railing = top:WaitForChild("Railing")
rWidth = railing.Size.X
test1 = railing.Position - Vector3.new(0,2,0)
print(test1)
test2 = railing.Position - Vector3.new(0,4,0)
print(test2)
ray = Ray.new(railing.Position, Vector3.new(0,-2,0)).unit
place = game.Workspace:FindPartOnRay(ray, nil)
print(place)
The problem is that it always sends back nil. The ray is supposed to look strait down from railing, but it always returns nil. I surrounded railing with bricks to see if it was going in the wrong direction, but it was still nil. Even substituting the railing position for test1 (which is just the railing Position lowered by 2) doesn't change the result. What am I doing wrong?
