Welp, here's the code:
local door = script.Parent door.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then if hit.Parent.Name == "CaptaiinNoob" or "Mixer90" then door.StatDoor.Transparency = 1 door.StatDoor.CanCollide = false wait(.5) door.StatDoor.Transparency = 0 door.StatDoor.CanCollide = true else hit.Parent.Head.CFrame = CFrame.new(132.9, 3.199, -164.2) end end end)
Put into a script and is a child of the door. ^
The door is called StatDoor, look at lines 6-10...
If your script is in a Model and StatDoor is name of a Part then this script will be perfect :-
local door = script.Parent local waittime = "0.5" --time between open and close local telepos = "132.9, 3.199, -164.2" --position to teleport others door.StatDoor.Touched:connect(function(hit) --I think you had did mistake here, from your qustion it seems like script is in a model not in a part, if it is then it might be main reason for your script is not working. if game.Players:FindFirstChild(hit.Parent.Name) then --Checking that if it's a player's Character. if hit.Parent.Name == "CaptaiinNoob" then -- check if the player is "CaptaiinNoob" work() elseif hit.Parent.Name == "Mixer90" then --check if the player is "Mixer90" work() else hit.Parent.Head.CFrame = CFrame.new(Vector3.new(telepos)) --if the player is none of them then teleports them to selected locaion end end end) function work() --creating a function so you can call it anytime just by writing "work()" --door open door.StatDoor.Transparency = 1 door.StatDoor.CanCollide = false --wait wait(waittime) --door close door.StatDoor.Transparency = 0 door.StatDoor.CanCollide = true end
Notice that script.Parent
Must be a Model
and script.Parent.StatDoor
must be a Part
and script
must be child of the Model
if hit.Parent.Name == "CaptaiinNoob" or hit.Parent.Name == "Mixer90" then
You need to do it like that, and it should work I think..
local door = script.Parent door.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then if hit.Parent.Name == "CaptaiinNoob" or hit.Parent.Name == "Mixer90" then door.StatDoor.Transparency = 1 door.StatDoor.CanCollide = false wait(.5) door.StatDoor.Transparency = 0 door.StatDoor.CanCollide = true else hit.Parent.Head.CFrame = CFrame.new(132.9, 3.199, -164.2) end end end)
Works perfectly for me.