How can I stop the arrow from turning?

How can I stop the arrow from turning?

3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked around on the dev forum and asked some discord servers.

My code is in a localscript in startcharacterscripts. Here is my code:

while wait(1.3) do
	local num = game.Players.LocalPlayer:WaitForChild('leaderstats',math.huge):WaitForChild('Stage')
	if num then
		game.TweenService:Create(game.Workspace.Pointer,TweenInfo.new(math.random(7,13)/10), {CFrame =( workspace.Checkpoints:FindFirstChild("Checkpoint "..num.Value+1) or workspace.Checkpoints["Checkpoint "..num.Value]).CFrame*CFrame.new(2,math.random(3,5),0)}):Play()
end end
1 Like

to stop the loop you should use a “break”

for example:

local value = true

while task.wait(1) do
  if value then
   print("Value is true continuing the loop")
  else if not value then
   print("Value is false breaking the loop")
   break; -- breaks the loop
  end
end

task.wait(10)

value = false
1 Like

Try adding 90 degrees to your CFrame angles value. I bet your Arrow Orientation is 90 degrees to where you expect it to be.
In Studio select the Arrow and look at it’s Orientation. If your CFrame values are 90 degrees out it’ll move to that new Orientation.

1 Like

try changing the orientation/cframe.angles at the same time.

The behavior you’re seeing is likely due to the TweenService creating a smooth transition between two CFrame positions. The arrow turns because the transition interpolates the rotation as well. To prevent the arrow from turning during the transition, you can explicitly set the rotation of the new CFrame to match the arrow’s current rotation. Here’s how you can modify your code to achieve this:

luaCopy code

while wait(1.3) do
	local num = game.Players.LocalPlayer:WaitForChild('leaderstats', math.huge):WaitForChild('Stage')
	if num then
		local targetCheckpoint = workspace.Checkpoints:FindFirstChild("Checkpoint " .. num.Value + 1) or workspace.Checkpoints["Checkpoint " .. num.Value]
		if targetCheckpoint then
			local arrow = game.Workspace.Pointer
			local currentRotation = arrow.CFrame - arrow.Position -- Extract the rotation from the arrow's CFrame
			local targetCFrame = targetCheckpoint.CFrame * CFrame.new(2, math.random(3, 5), 0)
			local newCFrame = CFrame.new(targetCFrame.Position) * currentRotation -- Apply the same rotation to the new position

			game.TweenService:Create(arrow, TweenInfo.new(math.random(7, 13) / 10), { CFrame = newCFrame }):Play()
		end
	end
end

This code calculates the arrow’s current rotation by subtracting its position from its CFrame. Then, it applies the same rotation to the new position to keep the arrow from turning during the transition.

1 Like

This works, thank you! I do have a question, why does it go to the right of the checkpoint? It doesn’t rotate but it does shift over to the right side of the checkpoint.

Sorry for the very late response haven’t checked forums in a little bit

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.