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

Why won't my door change positions?

I am trying to make a door, and it will not move. Can someone help? The error says " 13:43:45.705 - X cannot be assigned to"

here's my script:




script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		script.Parent.Position.X = script.Parent.Position.X - 6
	end
end)



1 comment

0

Try "script.Parent.Position = Vector3.new(script.Parent.Position.X - 6, script.Parent.Position.Y, script.Parent.Position.Z)

1 answer

That's because you can't change a particular axis of a Vector3 value. You have to instead change the whole Vector3 at once.

-- Instead of doing this:
script.Parent.Position.X = script.Parent.Position.X - 6

-- Do this instead:
script.Parent.Position = script.Parent.Position - Vector3.new(6,0,0)

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