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

[CLOSED] Simple owner door script not working? I see no problems in it.

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

2 comments

0

Any errors?

0

Do you have FilteringEnabled on or something?

3 answers

✓ Accepted answer

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

2 comments

0

This has been closed already, the door is called StatDoor. I jsut had to fix a few lines. But thanks for the effort! I'll accept because I'm nice. :3

0

Thanks :D

if hit.Parent.Name == "CaptaiinNoob" or hit.Parent.Name == "Mixer90" then

You need to do it like that, and it should work I think..

1 comment

0

I think you're right about that. But it still doesn't work.

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.

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