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

How do I make Rotations work using Vector3.new() with 'or' in between the numbers?

Asked by 9 years ago

What I am asking is this. I made a script where when I click it, it rotates to the number I provided. Well, just in case if people moved it around, I want it to still work so I added another numbers to make it work. So, let's say if I move it anywhere and rotate the whole model, I want it to still work no matter where it is. If the Rotation is this 'or' that, then it should still work. That is what I want it to happen. This is the script to make it more sense:

01local tune = game.Workspace.Radio.Tune
02local pic = workspace.SongPosters.Decal
03sound = Instance.new("Sound", tune)
04debounce = false
05radioOn = false
06 
07function onClicked()
08    if debounce then return end --Stop the function if debounce is true.
09    debounce = true
10    if not radioOn then
11        radioOn = true
12        tune.Rotation = Vector3.new(tune.Rotation.X, -69.598, tune.Rotation.Z or 20.084, tune.Rotation.Y, tune.Rotation.Z)
13        pic.Texture = "rbxassetid://174956680"
14        sound.SoundId = "rbxassetid://142295308" --Playing It's Raining Tacos
15        sound:Play()
View all 26 lines...
1
Your errors are on lines 12 and 19; You have set up more Arguments than you need (it only requires 3, you gave it 5 arguments). :) TheeDeathCaster 2368 — 9y
1
What are you trying to accomplish with `or`? Picking randomly? BlueTaslem 18071 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

The "or" operator returns its first statement if it is not false, otherwise it returns its second argument. Using "or" like this will always position the CFrame to "tune.Rotation.X, -69.598, tune.Rotation.Z", because that is a "true" statement.

I would recommend checking the current CFrame of the brick, and rotating it based on whichever the CFrame is. Upvote if this helped.

Ad

Answer this question