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

How the heck does repeat work anymore?

Asked by 4 years ago
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)
0
What happens when the function runs? Does it keep on going? OddExistent 52 — 4y
0
It stops. if it is == it never stops MadnessMyth 10 — 4y
0
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. IStarConquestI 414 — 4y
0
Well if i make it to a == It keeps repeating Non Stop if it is <= Or >= It will not stop How do fix this? MadnessMyth 10 — 4y
View all comments (7 more)
0
As I previously stated, you cannot use comparison operators on vector3s. IStarConquestI 414 — 4y
0
do i remove Vector3 or add Vector2? then MadnessMyth 10 — 4y
0
Try comparing the Position.X, Position.Y, etc. instead of comparing the whole position to a Vector3 Mayk728 855 — 4y
0
is this correct? until script.Parent.Parent.Glass.Position.Y >= (8.705) MadnessMyth 10 — 4y
1
Use TweenService to solve this. It is highly inefficient to adjust a position with repeat scopes.  Ziffixture 6913 — 4y
0
i dont know how to use Tween serivce can u just rewrite the entire script for me? MadnessMyth 10 — 4y
0
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. guest_20I8 266 — 4y

3 answers

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
0
Where do i put the code? MadnessMyth 10 — 4y
0
In your script, just replace it Ziffixture 6913 — 4y
0
i will accpept this answer Since it involed Tween Serivce MadnessMyth 10 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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)
0
im two dumb to understand what to do lol MadnessMyth 10 — 4y
0
Look it up and try to understand it. If u still need help, I can rewrite your script if u need. OddExistent 52 — 4y
0
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 MadnessMyth 10 — 4y
0
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 OddExistent 52 — 4y
View all comments (9 more)
0
Also, make it the same size as your glass part. Then, put your new part where you want the glass piece to go. OddExistent 52 — 4y
0
okay doin dat. MadnessMyth 10 — 4y
0
diid dat wat now MadnessMyth 10 — 4y
0
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) OddExistent 52 — 4y
0
of course, the newPart is the invisible part that I told you to put as the target OddExistent 52 — 4y
0
the newpart word has red below it? MadnessMyth 10 — 4y
0
the newPart is the part that i told you to create and make invisible. OddExistent 52 — 4y
0
it still inst working i renamed it and everything. MadnessMyth 10 — 4y
0
Make sure you have no spelling mistakes. I put your script in my answer, so maybe that should work. OddExistent 52 — 4y
Log in to vote
0
Answered by 4 years ago

im going to watch a video on how to do this So i tell everyone if it worked or not.

0
i think i have it working MadnessMyth 10 — 4y
0
Okay great OddExistent 52 — 4y

Answer this question