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

[ANSWERED]How do I make this script target other bricks within the model?

I have a clickable brick with a script inside that executes this action when clicked. However, I can't make the water appear or make it go back to it's original position.

function onClicked(playerWhoClicked)
	script.Parent.Position = Vector3.new(92, 12.401, 87.5) --91.7, 12.401, 87.2 is original
	script.Parent.Rotation = Vector3.new(0, -0, 0) --0, 0, 0 is orignal
	script.Water.Transparency = 0.5
	wait(3)
	script.Parent.Position = Vector3.new(91.7, 12.401, 87.2)
	script.Parent.Rotation = Vector3.new(0, 0, 0)
	script.Water.Transparency = 1
end

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

EDIT: This script is inside a brick inside a model. The "Water" in the script is a part inside the model as well

6 comments

0

NOTE: The "Water" is what the brick is called that I want to appear, and the lines after "wait" won't work

0

You can edit your question, you know.

0

Debounce is key.

0

I feel like a denounce wouldn't be necessary. I'm using a brick that's clicked on instead of touched by the player.

1

You can still spam click.

0

So it would "script.Parent.Parent" since the script is inside a brick in the model, correct? No, then you would be moving the whole model itself.

1 answer

✓ Accepted answer

Your script looks fine, minus line 4 and 8. I don't know if you have a part called Water inside of your script, if it's not inside of your script then it is wrong. Also, you are using Position so if any part will be in the area this part called Water will be, when you move it, the part will go on top of another part. You said nothing about it moving somewhere and ending up too high, so i'll assume that's not happening.

So, I don't know your layout but I think you Hierarchy may be incorrect. If script is inside of a model and so is water, you want to do script.Parent.Water.Transparency = 0.5 Other than what I said are possibilities, I believe your script is fine.

2 comments

0

The script is inside a brick, that's in a model, to hopefully get rid of any confusion. I'm actually trying to make an interact-able faucet to my game, and hopefully I can reuse this script to make some clickable doors.

0

So it would "script.Parent.Parent" since the script is inside a brick in the model, correct?

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