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

How to make a disappearing door with OnClick func and variables (roblox lua)?

I made the variable to search for the door then im stuck on how to make the transparency set to .5 then the CanCollide false. So basically this?

Local Door = script.Parent ????????? ????

4 comments

1

is the door a Model, or a singular part?

0

a singular part

0

Did you try a different way?

1 answer

✓ Accepted answer

Assuming you already have the ClickDetector object inside of the door:

Hello!

So basically, you need to use this:

 -- IN A SERVER SCRIPT, INSIDE OF THE DOOR --
local door = script.Parent  -- door variable
local cD = script.Parent.ClickDetector  -- click detector
local event = game.ReplicatedStorage.Clicked -- This will be used to make the door LOCAL, so that people cannot get through with their friends.

cD.MouseClick:Connect(function(player)  -- gets the player after a click
	event:FireClient(player, door)  -- fires onto client
end)

 -- IN A LOCALSCRIPT, IN STARTERPLAYERSCRIPTS --

local event = game.ReplicatedStorage:WaitForChild("Clicked")  -- gets the event

event.OnClientEvent:Connect(function(door)  -- when the event is fired
	door.CanCollide = false -- canCollide false
	door.Transparency = 0.5 -- transparency 0.5
	wait(1) -- change to whatever you'd like
	door.Transparency = 0  -- transparency = 0
	door.CanCollide = true  -- canCollide true
end)

Hope this works!

2 comments

0

that seems very in depth max, is there a shorter version?

0

There could be, this is just "visually in-depth." Really all it's doing is asking it's "friend", if you will, to open a door for this player.  Glad I could help! :)

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