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

How would I make a brick change size starting when a ClickDetector is clicked? [Partly Answered]

This is what I've tried..

script.Parent.OpenButton.ClickDetector:OnClick()
script.Parent.Door.Size = 20, 15, 0.6
wait(1)
script.Parent.Door.Size = 20, 14, 0.6
wait(1)
script.Parent.Door.Size = 20, 13, 0.6

etc. Any ideas?

3 answers

✓ Accepted answer

You have no connection lines, and Size is a Vector3 value meaning when you set it equal to something, it has to be a Vector3 value:

script.Parent.OpenButton.ClickDetector.MouseClick:connect(function() -- Simpler way to use functions and connection lines
	script.Parent.Door.Size = Vector3.new(20,15,0.6) --Assigning a new Vector3 value to size
	wait(1) --Waiting one second
	script.Parent.Door.Size = Vector3.new(20,14,0.6) --Again
	wait(1) --Again
	script.Parent.Door.Size = Vector3.new(20,13,0.6) --Yet again
end) -- Parenthesis closes the connection line and end ends the function

theres not much wrong with your code except your connection line try this

function openButton()
	script.Parent.Parent.Size = 20, 15, 0.6 -- i change door to parent
	wait(1)
	script.Parent.Parent.Size = 20, 14, 0.6 --im assuming script is child of click detector which is child of door
	wait(1)
	script.Parent.Parent.Size = 20, 13, 0.6
end
script.Parent.MouseClick:connect(openButton)


this should work

1 comment

0

It got an argument where we were setting the size, it expected a Vector3. I forgot how to work that, do you mind editing it real quick?

put this script as child of ClickDetector

script.Parent.MouseClick:connect(function(click) if click then
script.Parent.Parent.Size = Vector3.new(20,15,0.6)
wait(1)
script.Parent.Parent.Size = Vector3.new(20,14,0.6)
wait(1)
script.Parent.Parent.Size = Vector3.new(20,13,0.6)
end end)

2 comments

0

That didn't work, and just a reminder, there's a LUA button that lets you put code in it, for it to look like it does in studio.

0

Put the ClickDetector in the "door" then put a script in the ClickDetector and copy and paste the code above into the script. It should work. it worked for me.

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