Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to subtract from a negative number?

I'm trying to subtract negative 0.05 each time it loops, I've tried +-0.05, --0.05 and others but they wont work! I'm sorry if I didn't explain it well because its hard for me to explain.

for turn= 1,-0.5,  -0.05 do 
	wait()	
	script.Parent.Head.CFrame = script.Parent.Head.CFrame * CFrame.Angles(0,turn,0)
	end

2 comments

0

Why not just add the number.... subtracting a negative is the same as adding?

0

how would you do that?

1 answer

✓ Accepted answer

Ask yourself this question:

How many times do you want the loop to run?

Lets say you want it to run 10 times, you could do this:

local head = script.Parent.Head

for i = 1, 10 do
	wait()
	head.CFrame = head.CFrame * CFrame.Angles(0, -.05, 0)
end

From what I understand, you want it to rotate at a constant rate. In your example, the amount it rotates changes each time you loop through.

Note that CFrame.Angles uses radians, if you were using degrees and don't know the radian conversion, simply use math.rad(number).

local head = script.Parent.Head

for i = 1, 10 do
	wait()
	head.CFrame = head.CFrame * CFrame.Angles(0, math.rad(-.05), 0)
end

2 comments

0

Thank you so much!

0

My pleasure!

This discussion is preserved as it was. New answers, comments, and votes are closed.