local clickdetector = script.Parent:WaitForChild("ClickDetector") clickdetector.MouseClick:Connect(function() local TweenService = game:GetService("TweenService") local part = workspace:WaitForChild("stop") local part1 = workspace:WaitForChild("stop1") local part2 = workspace:WaitForChild("stop2") local TweenInfo = TweenInfo.new(50); local goals = {}; goals.CFrame = part1.CFrame; local Tween = TweenService:Create(part, TweenInfo, goals) Tween:play() end)
That will get the part from one brick to another, but I cant figure out how to make the brick come back and forth, and for that to happen an infinite number of times.
This is what the TweenInfo is for :)
Configure the EasingDirection parameter to Enum.EasingDirection.InOut
. Put the RepeatCount to math.huge
so it repeats forever.
local TweenService = game:GetService("TweenService") local clickdetector = script.Parent:WaitForChild("ClickDetector") local part = workspace:WaitForChild("stop") local part1 = workspace:WaitForChild("stop1") local part2 = workspace:WaitForChild("stop2") local TweenInfo = TweenInfo.new( 50, --Duration of tween Enum.EasingStyle.Quad, --Style Enum.EasingDirection.InOut, --Direction math.huge, --RepeatCount true --Reverses(goes back to start) ) local goals = {}; local click; click = clickdetector.MouseClick:Connect(function() goals.CFrame = part1.CFrame; local Tween = TweenService:Create(part, TweenInfo, goals) Tween:play() click:Disconnect() --Disconnect RbxScriptSignal after clicking end)