Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Rotating Block Script Kills Me-- Help?

Asked by 9 years ago
01local Unique = Workspace.Unique
02local URotation = Unique.Rotation
03function onTouch(Unique)
04    Unique.Rotation = Vector3.new(15,0,0)
05    wait(1)
06    Unique.Rotation = Vector3.new(30,0,0)
07    wait(1)
08    Unique.Rotation = Vector3.new(45,0,0)
09    wait(1)
10    Unique.Rotation = Vector3.new(60,0,0)
11    wait(1)
12    Unique.Rotation = Vector3.new(75,0,0)
13    wait(1)
14    Unique.Rotation = Vector3.new(90,0,0)
15    wait(1)
View all 27 lines...

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

Log in to vote
0
Answered by
Decemus 141
9 years ago

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

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

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

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

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

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! LegendaryHeroRigel 10 — 9y
0
No problem. Decemus 141 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
01local Unique = game.Workspace.Unique
02local URotation = Unique.Rotation
03Unique.Touched:connect(function(hit)
04    URotation = Vector3.new(15,0,0)
05    wait(1)
06    URotation  = Vector3.new(30,0,0)
07    wait(1)
08   URotation  = Vector3.new(45,0,0)
09    wait(1)
10   URotation  = Vector3.new(60,0,0)
11    wait(1)
12   URotation  = Vector3.new(75,0,0)
13    wait(1)
14   URotation  = Vector3.new(90,0,0)
15    wait(1)
View all 26 lines...

Maybe this will work.

Answer this question