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)
How the heck does repeat work anymore?
3 answers
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)
3 comments
Where do i put the code?
In your script, just replace it
i will accpept this answer Since it involed Tween Serivce
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)
13 comments
im two dumb to understand what to do lol
Look it up and try to understand it. If u still need help, I can rewrite your script if u need.
i dont know what to search two this is why i went to scriptinghelpers website i would really like that u rewrite my script(Only the repeat part of the script) thanks
Okay. So u shouldn't use repeat, use the lerp function. First, I want you to create a part, make it invisible, anchor it, and turn can collide off
Also, make it the same size as your glass part. Then, put your new part where you want the glass piece to go.
okay doin dat.
diid dat wat now
Okay, so now replace this with your repeat section of your script: local glass = script.Parent.Parent.Glass; glass.CFrame = glass.CFrame * CFrame.new():lerp(newPart.CFrame,.5)
of course, the newPart is the invisible part that I told you to put as the target
the newpart word has red below it?
the newPart is the part that i told you to create and make invisible.
it still inst working i renamed it and everything.
Make sure you have no spelling mistakes. I put your script in my answer, so maybe that should work.
im going to watch a video on how to do this So i tell everyone if it worked or not.
2 comments
i think i have it working
Okay great
This discussion is preserved as it was. New answers, comments, and votes are closed.

11 comments
What happens when the function runs? Does it keep on going?
It stops. if it is == it never stops
I don't know what the question is supposed to be, but on line 4, you attempt to compare 2 vectors which should yield an error.
Well if i make it to a == It keeps repeating Non Stop if it is <= Or >= It will not stop How do fix this?
As I previously stated, you cannot use comparison operators on vector3s.
do i remove Vector3 or add Vector2? then
Try comparing the Position.X, Position.Y, etc. instead of comparing the whole position to a Vector3
is this correct? until script.Parent.Parent.Glass.Position.Y >= (8.705)
Use TweenService to solve this. It is highly inefficient to adjust a position with repeat scopes.
i dont know how to use Tween serivce can u just rewrite the entire script for me?
like @Feahren said, use TweenService. Go to youtube or somewhere to search for tutorial, this is not a free script website. There's not excuse to say "I don't know how" because there's so much information out there these days.