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

Rotating Block Script Kills Me-- Help?

local Unique = Workspace.Unique
local URotation = Unique.Rotation
function onTouch(Unique)
	Unique.Rotation = Vector3.new(15,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(30,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(45,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(60,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(75,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(90,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(105,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(120,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(135,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(150,0,0)
	wait(1)
	Unique.Rotation = Vector3.new(165,0,0)
	wait(1)
end
Unique.Touched:connect(onTouch)

I'm just doing this for practice. So, I'm basically just a beginner scripter, I have no idea how Vector3 works. I made this by basically patching other pieces of code together. The script is apparently supposed to make the block I touch rotate 15 degrees every second, but when I touch it, it kills me instead. Help?

Additional Info: Unique is the name of the part that I'm trying to make rotate. It's named Unique in an attempt to stop it from contradicting with any of my body parts.

Also, if you have any way of making this less tedious, please let me know.

2 answers

✓ Accepted answer

Well, to start off, Unique could be any brick, as such. Get rid of the unique in parentheses, because it is rotating you instead of the brick. Then, add a debounce, like doing

debounce = false
[INSERT FUNCTION HERE]
if debounce = false then -- so you don't spam it a lot of times
debounce = true -- stop it from doing the function over again
[body of function]
wait(#) -- switch # to how long before the function plays again
debounce = false

Also, you can switch it to a for loop. like

for i=1,11 do
Unique.Rotation = Vector3.new(Unique.Rotation.x + 15,0,0)
    wait(1)

Instead of doing Workspace.Unique, do script.Parent.

2 comments

0

Although the rest of the script didn't work, I made a variable for game.Workspace.Unique.Script.parent, and used it to replace the Unique in the parenthesis, and it worked! Thanks!

0

No problem.

local Unique = game.Workspace.Unique
local URotation = Unique.Rotation
Unique.Touched:connect(function(hit)
    URotation = Vector3.new(15,0,0)
    wait(1)
    URotation  = Vector3.new(30,0,0)
    wait(1)
   URotation  = Vector3.new(45,0,0)
    wait(1)
   URotation  = Vector3.new(60,0,0)
    wait(1)
   URotation  = Vector3.new(75,0,0)
    wait(1)
   URotation  = Vector3.new(90,0,0)
    wait(1)
    URotation  = Vector3.new(105,0,0)
    wait(1)
    URotation  = Vector3.new(120,0,0)
    wait(1)
   URotation  = Vector3.new(135,0,0)
    wait(1)
    URotation  = Vector3.new(150,0,0)
    wait(1)
   URotation  = Vector3.new(165,0,0)
    wait(1)
end

Maybe this will work.

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