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

Why is Y cannot be assigned appearing? Error in output

Asked by 6 years ago

I scripted this in like 2 minutes, basically, I made a model in my game so whenever a player steps on it, it would fall down and disappear then after the cooldown it will reappear, basically like an obstacle.

It says in the output: Y cannot be assigned to (line 11)

01local cooldown = 4
02 
03for _,v in pairs(script.Parent:GetChildren()) do
04    if v.Name == 'Script' then return end
05    if v:IsA("BasePart") then
06        v.Touched:Connect(function(hit)
07            if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
08                wait(1)
09                spawn(function()
10                    for i = 0, 20, 1 do
11                        v.Position.Y = v.Position.Y - i
12                        wait()
13                    end
14                end)
15                v.CanCollide = false
View all 35 lines...
0
X, Y, Z are read-only, you cannot edit them. Elixcore 1337 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Y is a read only value. To change the Y value you would add or subtract a vector three. For example, lets say I want to move a block a certain amount of studs down.

1local i = 4
2function move(object)
3object.Position = object.Position - Vector3.new(0,i,0)
0
(Yeah I didnt put in an end but its an example and im too lazy to edit) TiredMelon 405 — 6y
Ad

Answer this question