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

how to make a part need to stay on a button?

im making a puzzle game and one of the main things is putting a part on a buton to open a door. i made a simple script that changes the button's color when you put the part on it.

script.Parent.Touched:connect(function(hit)
	if hit.Name == "qb" then 
		
		script.Parent.BrickColor = BrickColor.new("Really red")
		
	end
end)

how do i make it so that the color changes back when thepart stops standing on the button? i will change the color changing into opening doors later.

1 comment

0

You could use the TouchEnded event to accomplish this. See: https://create.roblox.com/docs/reference/engine/classes/BasePart#TouchEnded

1 answer

Here is how you can use invalidinvoke's suggestion TouchEnded event

script.Parent.Touched:connect(function(hit)
    if hit.Name == "qb" then 
        script.Parent.BrickColor = BrickColor.new("Really red")
	script.Parent.TouchEnded:Connect(function(HitEnd)
	--do stuff

    end
end)

Hope this helps!!

2 comments

0

place it outside script.Parent.Touched NOT INSIDE

0

Why I don't think that makes a difference

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