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 5 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)

local cooldown = 4

for _,v in pairs(script.Parent:GetChildren()) do
    if v.Name == 'Script' then return end
    if v:IsA("BasePart") then
        v.Touched:Connect(function(hit)
            if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
                wait(1)
                spawn(function()
                    for i = 0, 20, 1 do
                        v.Position.Y = v.Position.Y - i
                        wait()
                    end
                end)
                v.CanCollide = false
                for i = 0, 1, 0.1 do
                    v.Transparency = v.Transparency + i
                    wait()
                end
                wait(cooldown)
                spawn(function()
                    for i = 0, 20, 1 do
                        v.Position.Y = v.Position.Y + i
                        wait()
                    end
                end)
                v.CanCollide = true
                for i = 0, 1, 0.1 do
                    v.Transparency = v.Transparency + i
                    wait()
                end
            end
        end)
    end
end
0
X, Y, Z are read-only, you cannot edit them. Elixcore 1337 — 5y

1 answer

Log in to vote
1
Answered by 5 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.

local i = 4
function move(object)
object.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 — 5y
Ad

Answer this question