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

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

Asked by 6 years ago
Edited 6 years ago

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

0
Any errors? xAtom_ik 574 — 6y
0
Do you have FilteringEnabled on or something? Nep_Ryker 131 — 6y

3 answers

Log in to vote
0
Answered by 6 years ago

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

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 CaptaiinNoob 52 — 6y
0
Thanks :D TheSkyofIndia 150 — 6y
Ad
Log in to vote
0
Answered by
Nep_Ryker 131
6 years ago
Edited 6 years ago
if hit.Parent.Name == "CaptaiinNoob" or hit.Parent.Name == "Mixer90" then

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

0
I think you're right about that. But it still doesn't work. CaptaiinNoob 52 — 6y
Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
6 years ago
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.

Answer this question