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

Why is Y cannot be assigned appearing? Error in output

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

1 comment

0

X, Y, Z are read-only, you cannot edit them.

1 answer

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)

1 comment

0

(Yeah I didnt put in an end but its an example and im too lazy to edit)

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