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 8 years ago
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

Log in to vote
0
Answered by
Decemus 141
8 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

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.

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 — 8y
0
No problem. Decemus 141 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
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.

Answer this question