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

I've Managed To Mess Up This Loop, How?

Asked by 10 years ago

Hey guys. I've been trying to make a script that subtracts the position by .1 and the size by .2, so that it looks like sliding glass. This is my loop:

Shield = script.Parent

while script.Parent.Size.Y > 0.2 do
    Shield.Size.Y = Shield.Size.Y - .2
    Shield.CFrame.Y = Shield.CFrame.Y - .1
    wait(.05)
end
script.Parent.CanCollide = false

The error it throws is as follows: Y cannot be assigned to Script 'Workspace.Shield.Script', Line 4 Thanks in advance, Aurum

0
The individual parts of a Vector3 are read-only; you need to modify the entire thing. The answer given by ipiano should should work. 2eggnog 981 — 10y

1 answer

Log in to vote
0
Answered by
ipiano 120
10 years ago

Well... I'm not sure why you get that error, so this solution may not work, but instead of modifying just the Y part of the Vector3Value, subtract a whole Vector3 like this

Shield.Size = Shield.Size - Vector3.new(0, 0.2, 0)
Shield.CFrame = Shield.CFrame - Vector3.new(0,0.1,0)

Let me know if that works!

0
Thanks, works great. SquirreIOnToast 309 — 10y
Ad

Answer this question