I’m not using the functions, so I don’t see why this matters.
I am stumped… I made a simpler script to test yours and it works fine:
It rotates 90 degrees each time then places a red brick at the end of the ray:
(this is after its gone around 360 degrees already)
the print statement is showing the cframe look vector updated as well:
Im very confused to why yours isnt working
Yeah, same. When I looked it up, my script was always what people used.
Then for the Ray
, you dont need to raycast, you only need to worry about workspace:Raycast
depending on what youre using it for, all you can do this just this:
local origin, dir = part.Position, part.CFrame.LookVector*5
local cast = workspace:Raycast(origin, dir, params)
Nothing changes
So just 1 more time, you say that this print statement print("NEW RAYS", part.CFrame.LookVector)
is printing the same vector each time, regardless of how the brick is rotated? could it at all be possible that the turn function is referencing a different part than the heartbeat function is? That print is probably the most surefire test to see if the part is actually being changed… if its not printing different values than i can only conclude that your turn function is rotating a different part than what you are taking the position and lookvector from in the heartbeat function.
Try adding a part parameter to turn just to be sure:
local function turn(part, direction)
turning = true
local mult = if direction == "left" then 1 else -1
for i=0, 90 * mult, mult do
task.wait()
part.Orientation += Vector3.new(0, mult, 0)
end
turning = false
end
and then call it in the heartbeat:
if --[[math.random(1, 3) == 1 or]] frontCast and frontCast.Instance then
print("turning left")
turn(part, "left")
turned = true
end
if --[[math.random(1, 3) == 1 or]] frontCast and frontCast.Instance then
print("turning right")
turn(part, "right")
end
Yeah, nothing changes. I don’t see the point in changing it.
Part is defined only once, and it’s also literally the only part not in a folder, but I’ll test this.
This somehow is the solution. No idea why this works, but it does. Thank you so much for your help!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.