Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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 ????????? ????

1
is the door a Model, or a singular part? Despayr 505 — 4y
0
a singular part Electricshocker1234 5 — 4y
0
Did you try a different way? KamKam_AJHasBeenBan 37 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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!

0
that seems very in depth max, is there a shorter version? Electricshocker1234 5 — 4y
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! :) MaximussDev 86 — 4y
Ad

Answer this question