local PosPosPos = {
Pos1 = {UDim2.new(0.092, 0,0.2, 0), UDim2.new(0.861, 0,0.2, 0)},
Pos2 = {UDim2.new(0.092, 0,0.4, 0), UDim2.new(0.861, 0,0.4, 0)},
Pos3 = {UDim2.new(0.092, 0,0.7, 0), UDim2.new(0.861, 0,0.7, 0)},
}
local Randompos = PosPosPos["Pos"..math.random(1,3)]
local clone = selected:Clone()
local ObjectToTween = clone
repeat
ObjectToTween:TweenPosition(Randompos[2])
task.wait(1)
ObjectToTween:TweenPosition(Randompos[1])
until ended == true or killed == true
hello I have this game where the user tries to click the criminal thatās moving. Iām using tween to make the criminal move.
I use a repeat loop to tween the criminal until the player kills the criminal (HENCE the killed variable) i also have a variable to tell if the player loses the game (HENCE the ended variable)
I added a print() inside the repeat loop and the print plays normally however it seems the tween is only playing once but is being fired correctly every time the repeat, repeats.
my bad, Itās my fault. In the actual code it used
until killed == true or ended == true
the reason I typed it incorrectly in the help statement is because I changed some things, so to make it more simple to read/understand I wrote it from memory and not copy + paste.
all the changes I made I reverted because other bugs started appearing from those changes.
I also put a print inside the repeat loop and after the repeat loop and the repeat loop plays exactly as itās supposed to.
I tried printing inside of the repeat loop and it repeats until the proper time
same with the print after the repeat loop. It only plays at the correct time. The issue seems to be with the tween. I tried printing the positions of the tween and the positions are correct. I also tried printing the guiās current position and the tween position just in case it was tweening it to the same location for an unknown reason and itās not
Iām getting the follow error from your correction:
Players.SAKDEVRBLX_alt.PlayerGui.ScreenGui.Menu.Moving.Frame.LocalScript:123: attempt to index boolean with āCompletedā
while ended ~= true or killed ~= true do
ObjectToTween:TweenPosition(Randompos[2])
task.wait(1)
ObjectToTween:TweenPosition(Randompos[1])
task.wait(1)
end
:TweenPosition only has a callback after you Define the UDim2, TweenDirection, TweenStyle, Length, Override The callback will be assigned to a function
.Completed is not a callback for UDim2 built in tweens. you will need to use tweenservice for this
ah I see. I think tweenInstance.Completed:Wait() is more effective than waiting since the tween can take longer if the client is lagging. What variable is tweenservice?
local pathwayVelocity = TweenInfo.new(routeData[2], Enum.EasingStyle.Linear)
local pathwayMovement = bulletMovement:Create(bulletInstance, pathwayVelocity, {CFrame = routeData[1]}) -- bulletInstance is the object
pathwayMovement:Play()
pathwayMovement.Completed:Wait()
this is too complex for me, sorry I donāt understand it.
Like I said I havenāt even memorized the basic params.
I also see a lot of undefined variables that Iām āSupposedā to know what is.
Ah sorry I will replace all parameters with explanations below
local pathwayVelocity = TweenInfo.new(0.5, Enum.EasingStyle.Linear) -- Time to complete tween, easingStyle
local pathwayMovement = bulletMovement:Create(ObjectToTween, pathwayVelocity, {Position = Randompos[2]}) -- the object to tween, tweenInfo, and the property to tween (you may have to change the locations of each position to Vector3.new() instead of UDim2.new())
pathwayMovement:Play()
pathwayMovement.Completed:Wait()
but if the marked solution works then you should probably just use that I think