function myfunction() repeat wait() script.Parent.Parent.Glass.Position = script.Parent.Parent.Glass.Position + Vector3.new(0,0.1,0) until script.Parent.Parent.Glass.Position >= Vector3.new(-7.43, 8.705, 21.132) end script.Parent.ClickDetector.MouseClick:connect(myfunction)
You can use TweenService’s primary method :Create()
. This method will take three arguments, the Instance we wish to perform the action on, the information regarding the Tween, which can be seen below, and the goal, what property we want to interpolate, and where to finish at. This will return a TweenObject
, which we can use the :Play()
method to run, and use the .Completed
signal to call :Wait()
on so we can tell our program to wait until we’ve reached the new position.
local TweenService = game:GetService("TweenService") local Part = script:FindFirstAncestor("Glass") local ClickDetector = script.Parent local TweenInformation = TweenInfo.new( 2 --// Length Enum.EasingStyle.Out -- EasingStyle Enum.EasingDirection.Quint --// EasingDirection 0 --// repeat #n time(s) false --// should it repeat 0 --// delay ) local Goal = {Vector3 = Vector3.new(x,y,z)} local Tween = TweenService:Create(Part, TweenInformation, Goal) local function RunTween() Tween:Play(); Tween.Completed:Wait() end ClickDetector.MouseClick:Connect(RunTween)
Maybe use the CFrame:lerp() function. The first parameter is the target CFrame, and the second is the speed, a number between 0 and 1. This function will smoothly bring the object to the target position. Example:
part.CFrame = part.CFrame * CFrame.new():lerp(part.CFrame * CFrame.new(1,2,3),.5)
This will smoothly bring the part 1 unit across its x axis, 2 across its y, and 3 across its z. You can also set a new part as the target, make it transparent, and use that new part as the target parameter in the function.
part.CFrame = part1.CFrame * CFrame.new():lerp(targetPart.CFrame,.5)
First,create a part, make it invisible, anchor, and turn off can collide. Then, put it where you want your glass to go.This is going to be your new part. Then your script should look like this:
local glass = script.Parent.Parent.Glass local newPart = game.Workspace.newPart --this is your target part function myfunction() glass.CFrame = glass.CFrame * CFrame.new():lerp(newPart.CFrame,.5) end script.Parent.ClickDetector.MouseClick:connect(myfunction)
im going to watch a video on how to do this So i tell everyone if it worked or not.