so im trying to make a part be like a npc, and rn im making the movement. So ive already make it so it can move forward using tween but it just keeps going through the walls (he has a closed house) so how do i fix that?

here is the script:

local part = script.Parent

while true do

local distance = 10 local tween = game:GetService("TweenService"):Create(part, TweenInfo.new(1, Enum.EasingStyle.Linear), {CFrame = part.CFrame + (part.CFrame.LookVector * distance)})

tween:Play()
wait(4)
end

2 comments

0

Can't you set CanCollide of the part to true?

0

You probably should not be using tween for npc movement but if ur going to achieve it with tween then you should probably raycast towards where the npc is looking at and can tween it to where the ray is intersected at