Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tween flying back to origin point???

Asked by 6 years ago

I am trying to make a wander script that randomly picks orientations and distance to walk, and i am using the tweenservice to make it look smooth. For some reason all the parts the script is in keeps flying back to 0,0,0. Here is my script:

while true do
    wait(math.random(1,10))
    --turn
    local tweenService = game:GetService("TweenService")
    local part = script.Parent

    local tweeningInformation = TweenInfo.new(

    1.5, 
    Enum.EasingStyle.Linear, 
    Enum.EasingDirection.Out, 
    0,    
    false, 
    0  
    )

    local partProperties = {
    Orientation = script.Parent.Orientation + Vector3.new(0,math.random(1,180),0)

    }

    local Tween = tweenService:Create(part,tweeningInformation,partProperties)
    Tween:Play()
    wait(1.5)
    --move



    local tweeningInformation2 = TweenInfo.new(

    1.5, 
    Enum.EasingStyle.Linear, 
    Enum.EasingDirection.Out, 
    0, 
    false, 
    0  
    )

    local partProperties2 = {
    Position = script.Parent.CFrame.lookVector * math.random(5,50)
    }

    local Tween = tweenService:Create(part,tweeningInformation2,partProperties2)
    Tween:Play()
    wait(1.5)

end

Any help????

P.S. the part i am trying to tween is a union

0
God dude, please indent that. T0XN 276 — 6y
0
I don't see what the problem is... I put the script into a simple union and tested it, and it worked just fine. It might not work if it's in a complicated union or if the union is anchored. ax_gold 360 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Line 43. change it to "Tween2". You're confusing the script.

0
I figured it out. On line 40 I should have done | Position = script.Parent.Position + script.Parent.CFrame.lookVector * math.random(5,50) Pumpk1n52 22 — 6y
Ad

Answer this question