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

How can i spin the Bottle?

Asked by 6 years ago

Hello, I am making a new game. I want to spin the Bottle. I think i am corret but this script isn't working.Can i get an help?

part = script.Parent
a = 0
local pigs
pigs = 1
while pigs do
    part.Orientation.Y = part.Orientation.Y + 0.01
    wait(0.001)
end
pigs = 0
b = math.random(0,15)
wait(b)
local playing = false
while playing do
    if playing == false then
        waittime = math.random(0,10)
        part.Orientation = Vector3.new(0,1,0) - Vector3.new(0,1,0)
        wait(waittime)
        playing = true
    end
end

Here is the Error. 14:20:09.192 - Stack Begin 14:20:09.192 - Script 'Workspace.Sise.SpinScript', Line 6 14:20:09.193 - Stack End

0
I don't think you can set a specific rotation value (X,Y,Z) pretty sure they're read only, so change it to part.Orientation = part.Orientation + Vector3.new(0,0.1,0) User#20388 0 — 6y
0
Can you give the error from outside the stack? sweetkid01 176 — 6y
0
Your script will never make it past that first while loop. User#21908 42 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Use Vector3 instead, not it's axis.

part = script.Parent
a = 0
local pigs
pigs = 1
while pigs do
    part.Orientation = part.Orientation + Vector3.new(0,0.1,0)
    wait()
end
pigs = 0
b = math.random(0,15)
wait(b)
local playing = false
while playing do
    if playing == false then
        waittime = math.random(0,10)
        part.Orientation = part.Orientation - Vector3.new(0,1,0)
        wait(waittime)
        playing = true
    end
end
Ad
Log in to vote
0
Answered by 6 years ago

I tested the code from outside the stack, and the error:

Y cannot be assigned to

Either do this:

while pigs do
    part.Orientation = Vector3.new(part.Orientation.X, (part.Orientation.Y + 0.01), part.Orientation.Z)
    wait(0.001)
end

or for some reason "part" becomes nil in the process

0
“Orientation.Y” is ReadOnly, that’s why. The way you did it should work. User#20279 0 — 6y

Answer this question