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

I tried making a script that changes the doors x size when a button is clicked, it doesn't work?

I was trying to make it so that when a player clicks a button the door changes its x position so that players can get through the door.

function onClicked()
script.Parent.Parent.Part.Size.X = script.Parent.Parent.Part.Size.X - 5
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 comments

0

What's the error? Did you mean to make it position not Size.X

0

No, I meant Size x. And the error is "X can not be assigned to"

1 answer

Unfortunately, you cannot change the size of a part that easily. You need to create a new Vector3 to do that.

For example, you can do this:

function onClicked()
local size = script.Parent.Parent.Part.Size
script.Parent.Parent.Part.Size = Vector3.new(size.X - 5, size.Y, size.Z)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

This is the same for changing the Position and the Orientation.

2 comments

0

Thank you, I am not trying to request right now but I have been trying to make it slide as in change by a little per second

0

Make a new question, I can't answer that in comments

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