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

I am trying to make it where if the code is 1 2 3 4 then the door becomes clear?

local door = script.Parent.Parent.Door
local text = script.Parent.Parent.Numbers.SurfaceGui.TextLabel
if text.Text == "1234" then
	script.Parent.ClickDetector.MouseClick:Connect(function()
		door.Transparency = 0.5
		door.CanCollide = false
	wait(3)
		door.CanCollide = true
		door.Transparency = 0
	end)
end

my script wont work I think its because the click detector part but I dont know

5 comments

0

0 is the opposite of Transparent if you want it to be Transparent set door = 1

0

no, because i want it to be where if the code is 1234 then when you click the green button "Enter" it makes the door a little transparent but not all the way. then after 3 seconds it goes back to normal

0

Then they can't go though

0

I will fix that hold up

0

Little transparent means translucent and translucent means light opague

3 answers

Hello, RareBIue!

You need to connect the events before making any tests, or the code may not connect the event, also, you can't directly refer to a value on a variable if you want to change it on a part

local door = script.Parent.Parent.Door --You can't place .Transparency here, as it would define the variable as being the value of the current transparency
local text = script.Parent.Parent.Numbers.SurfaceGui.TextLabel

script.Parent.ClickDetector.MouseClick:Connect(function() --First you connect the event
    if text.Text == "1234" then --After that, you do any needed checks
        door.Transparency = 0.5
        wait(3)
        door.Transparency = 0
    end)
end

NOTE: You're not setting door to be uncollidable, so the player will still collide with the door

You have to update and set the CanCollide properties. Example Script [Should Work]!

local Door = script.Parent.Parent:WaitForChild("Door") -- Wait for the child to load in, and get the door BasePart
local Text = script.Parent.Parent.Numbers.SurfaceGui.TextLabel
script.Parent.ClickDetector.MouseClick:Connect(function(plr) -- plr is the player who clicked
  if Text.Text == "1234" then
    Door.Transparency = 0.5 -- Set transparency to 0.5, semi-transparent
    Door.CanCollide = false -- Set CanCollide to false
    wait(3) -- wait 3 secs
    Door.Transparency = 0 -- Set Transparency to 0, opaque
    Door.CanCollide = true -- Set CanCollide to true.
  end
end)

If this works in your game, please mark this as a solution!

1 comment

0

Set 0.5 to 1 please

Your code is wrong since when does it receive "1234".

It should be this:

 local door = script.Parent.Parent.Door
 local text = script.Parent.Parent.Numbers.SurfaceGui.TextLabel
 function text.Text.print "1" 
 wait (1)
 function text.Text.print "12" 
 wait (1)
 function text.Text.print "123" 
 wait (1) 
 function text.Text.print "1234" 
 wait (1) 
 if text.Text == "1234" then
    script.Parent.ClickDetector.MouseClick:Connect(function()
        door.Transparency = 0.5
        door.CanCollide = false
    wait(3)
        door.CanCollide = true
        door.Transparency = 0
    end)
  end

Just saying, this what I think so I don't guarantee it will work but try it out.

1 comment

0

do you know lua? its missing like 4 ends, and those funcions don't even work

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