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

How can i spin the Bottle?

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

3 comments

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)

0

Can you give the error from outside the stack?

0

Your script will never make it past that first while loop.

2 answers

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

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

1 comment

0

“Orientation.Y” is ReadOnly, that’s why. The way you did it should work.

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