I made a script that has a model that will go in random directions with a LinearVelocity, the issue is, when it hits borders, I want it to go in the opposite direction of the borders.
The issue is the tornado ends up just ramming into a corner of the Barriers, and just is stuck their.
The Script:
local Model = script.Parent
local vel = Model:WaitForChild("LinearVelocity")
vel.VectorVelocity = Vector3.new(math.random(-400,400), 0, math.random(-400,400))
while true do
task.wait(3)
if not Model.Touched then
vel.VectorVelocity = Vector3.new(math.random(-400,400), 0, math.random(-400,400))
else
if Model.Touched then
Model.Touched:Connect(function(hit)
if hit.Parent.Name == "Border" then
if vel.VectorVelocity.X == 400 then
vel.VectorVelocity.X = -400
vel.VectorVelocity.Z = 400
else
if vel.VectorVelocity.X == -400 then
vel.VectorVelocity.X = 400
vel.VectorVelocity.Z = -400
end
end
end
end)
end
end
end