Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Tween flying back to origin point???

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

2 comments

0

God dude, please indent that.

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.

1 answer

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

1 comment

0

I figured it out. On line 40 I should have done | Position = script.Parent.Position + script.Parent.CFrame.lookVector * math.random(5,50)

This discussion is preserved as it was. New answers, comments, and votes are closed.