How do I make this button work on touch?

I want to make a button (part) where if you touch it, it goes from the color green to red, and it makes another part(s) go from being semi-transparent + uncancollide to not being transparent at all + cancollide (All of these things with a cooldown time that I can set so that after the time is over, it goes back to being a green button and the other part(s) being semi-transparent and uncancollide again).

NOTE: I don’t want to make it local for the user, I want to make it so that it works for everyone on the server.

An example is this game: Two Player Obby 2 - Roblox
(I want to make the same buttons as in this game)

How can I make such a thing?
(Please be thorough when explaining as I’m a beginner scripter)

3 Likes

This should do the trick i think…Good luck and have a good day! :happy3:

local otherPart1 = script.Parent.Parent.OtherPart1 -- Path to other Parts
local otherPart2 = script.Parent.Parent.OtherPart2 -- Path to other Parts
local waitTime = 0.5 -- Change to whatever you want

script.Parent.Touched:Connect(function()
	wait(waitTime)
	script.Parent.Color = Color3.fromRGB(91, 165, 51) --Changes the Color to whatever color you want
	wait(waitTime)
	otherPart1.Transparency = 1 -- Changes the Transparency to whatever you want
	otherPart1.CanCollide = false
	otherPart2.Transparency = 1 -- Does the same, but to another part
	otherPart2.CanTouch = false
end)

4 Likes

This is perfect, thank you so much!

Just one thing though if you don’t mind, as you can see in the video:


I made it so that one player jumps on one side and the other part(s) becomes untransparent and cancollide, how do I make it so that after let’s say 5 seconds, the same part(s) that went untransparent and cancollide, will become after those 5 seconds back to before (uncanccolide and semi-transparent)? Also, how do I make it so that after those same 5 seconds the button also goes back from red back to green?

Actually, I played around with the script and figured it out, thanks a lot though!! :smiley:

1 Like

Really sorry for not replying in time!!! Besides that tho, your games looks pretty nice, and I’m glad you were able to figure things out by yourself. Good luck on your game and hope you have a wonderful day once again! :happy3:

2 Likes

Thank you so so much! And don’t worry, don’t get me wrong but good thing you didn’t respond because I got to learn how to mess around with the script and get it to work! :happy3:

1 Like