local Open = false Admins = "alerttrains123","Player1" function Click() wait() if Click.Parent:findFirstChild("Humanoid") then for i = 1,#Admins do if Click.Parent.Name == Admins[i] then if Open == false then Open = true script.Parent.Parent.DoorO1.Transparency = "0" script.Parent.Parent.DoorO2.Transparency = "0" script.Parent.Parent.DoorO1.CanCollide = true script.Parent.Parent.DoorO2.CanCollide = true script.Parent.Parent.DoorC1.Transparency = "1" script.Parent.Parent.DoorC2.Transparency = "1" script.Parent.Parent.DoorC1.CanCollide = false script.Parent.Parent.DoorC2.CanCollide = false elseif Open == true then Open = false script.Parent.Parent.DoorO1.Transparency = "1" script.Parent.Parent.DoorO2.Transparency = "1" script.Parent.Parent.DoorO1.CanCollide = false script.Parent.Parent.DoorO2.CanCollide = false script.Parent.Parent.DoorC1.Transparency = "0" script.Parent.Parent.DoorC2.Transparency = "0" script.Parent.Parent.DoorC1.CanCollide = true script.Parent.Parent.DoorC2.CanCollide = true end end end end end script.Parent.ClickDetector.MouseClick:connect(Click)
I took part of this script from somebody else and tried to implement it with mine, sadly the door will not open when I click it
I think the problem is the Click is a function. When using a function like this, the parentheses should contain a word that represents the Player that clicked it. It can be named anything, but for the purposes of demonstration, let's name it "plr".
local Open = false Admins = "alerttrains123","Player1" function Click(plr) --plr is the Player who clicked wait() if plr.Character:findFirstChild("Humanoid") then --use Character to access the Player's model for i = 1,#Admins do if plr.Character.Name == Admins[i] then if Open == false then Open = true script.Parent.Parent.DoorO1.Transparency = "0" script.Parent.Parent.DoorO2.Transparency = "0" script.Parent.Parent.DoorO1.CanCollide = true script.Parent.Parent.DoorO2.CanCollide = true script.Parent.Parent.DoorC1.Transparency = "1" script.Parent.Parent.DoorC2.Transparency = "1" script.Parent.Parent.DoorC1.CanCollide = false script.Parent.Parent.DoorC2.CanCollide = false elseif Open == true then Open = false script.Parent.Parent.DoorO1.Transparency = "1" script.Parent.Parent.DoorO2.Transparency = "1" script.Parent.Parent.DoorO1.CanCollide = false script.Parent.Parent.DoorO2.CanCollide = false script.Parent.Parent.DoorC1.Transparency = "0" script.Parent.Parent.DoorC2.Transparency = "0" script.Parent.Parent.DoorC1.CanCollide = true script.Parent.Parent.DoorC2.CanCollide = true end end end end end script.Parent.ClickDetector.MouseClick:connect(Click)
I hope this helps. If you found my answer helpful, you can upvote and accept it!
You're attempting index your function name?
So yes, it's returning an error, because on line 5 and 7 you're saying 'Click.Parent', but 'Click' is a function value, not a variable.
So, i'm assuming you're attempting to check the player's name to open the door. For this you have to have a Parameter in your function that you're tying to your MouseClick event. Because the MouseClick event returns the player that clicked, then you can index the player through this parameter(:
Secondly, you're trying to define the 'Admins' through a singular variable.. if you do it like that then you will only get access to the first argument. Use a table, then iterate through it to check if they player that clicked is an 'Admin'.
And lastly, the Transparency value takes numbers for arguments, not strings. Take the numbers out of the quotations and then you're good(;
local Open = false Admins = {"alerttrains123","Player1"} --Made a table function Click(player) --'player' will be how you acces the player that clicked. wait() for i,v in pairs(Admins) do --Iterate through the 'Admin' table if v == player.Name then --Check if there's a match if Open == false then Open = true script.Parent.Parent.DoorO1.Transparency = 0 script.Parent.Parent.DoorO2.Transparency = 0 script.Parent.Parent.DoorO1.CanCollide = true script.Parent.Parent.DoorO2.CanCollide = true script.Parent.Parent.DoorC1.Transparency = 1 script.Parent.Parent.DoorC2.Transparency = 1 script.Parent.Parent.DoorC1.CanCollide = false script.Parent.Parent.DoorC2.CanCollide = false elseif Open == true then Open = false script.Parent.Parent.DoorO1.Transparency = 1 script.Parent.Parent.DoorO2.Transparency = 1 script.Parent.Parent.DoorO1.CanCollide = false script.Parent.Parent.DoorO2.CanCollide = false script.Parent.Parent.DoorC1.Transparency = 0 script.Parent.Parent.DoorC2.Transparency = 0 script.Parent.Parent.DoorC1.CanCollide = true script.Parent.Parent.DoorC2.CanCollide = true end end end end script.Parent.ClickDetector.MouseClick:connect(Click)