Why is this not working?

Im trying to make it so that a part’s position is equal to a part in the workspace named “player”, but after the first time I set it, when it gets to the repeat loop, it doesn’t change its position at all.

there aren’t any errors in the output.

			repeat
				clonedAttack.Position = game.Workspace:WaitForChild("playerModel").Position
			until task.wait(clockIn)
			
			
			for i = 1, 5 do
				task.wait(0.001)
				clonedAttack.Transparency -= 0.1
				clonedAttack.Position = game.Workspace:WaitForChild("playerModel").Position
				clonedAttack.Anchored = true
			end
			
			task.wait(clockOut)
			
			for i = 1,20 do
				task.wait(0.001)
				clonedAttack.Transparency += 0.05
				clonedAttack.CanCollide = false
			end
			
			clonedAttack:Destroy()

This is yielding your script by running forever.

2 Likes

That format… Is this part of script?
If so, can you show full script?

1 Like

Then how can I make it so until a specific time met, the position of the object will stop changing?

Use break command to get out of loop.

1 Like

No other script should be able to affect this, because its a module, which I only put functions into.

Plus, all of the values are valid

Have you tried tweening your part?

But how can I do this with repeat until?

No matter what kind of loop it is.

For @StarJ3M’s situation, he really should tween the part and yield the script until the tween finishes.

Tweening isn’t required at all though, and I don’t even want to yield the script because it will not even make my game playable since it’s a bullet hell Rythm game

All Im doing is moving the position of the part to a part cald “playerModel”

Then, can’t you just move the part? Why do you need the loop?

If you don’t want your script to yield, then you could use coroutines. Coroutines are basically threads that can run at the same time.
Otherwise, if you want them to always be in the same position you could weld them.

1 Like

if you want to constantly update a position of 1 part to another an easy way to do this is propertychangedsignal doing something like this

setup 2 parts in workspace 1 called part1 and other part2 use the below in a local script and move the other part manually or with a script, it will update part1 pos to part 2 everytime part2 position changes

workspace.Part2:GetPropertyChangedSignal('Position'):Connect(function()
      workspace.Part1.Position = workspace.Part2.Position
end)

if you want to stop it from setting to Part2 pos you can put if statement in there

1 Like

try using tweenservice ( ignore this

Personally, I don’t like to always use tween service to make a part smooth since it takes more code which would make it increasingly harder for me to digest the script If I need some changes.

Also, its not like for loops are broken or all of the sudden deprecated, I just want to know how to fix it in my strategy.