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

Only certain people can get through the door script?

Asked by 10 years ago

I can't get this script to work. Is there something that I typed wrong in it?

local door = script.Parent

function open() -- This Function will make the door open.
    door.CanCollide = false -- Makes players able to walk through door.

    for transparency = 0, 1, .1 do
        door.Transparency = transparency
        wait (.1)
    end
end
function close() -- This Function will close the door
    for transparency = 1, 0, .1 do
        door.Transparency = transparency
        wait (.1)
    end

    door.CanCollide = true -- Makes players unable to walk through door
end
function get_player(part) -- This function returns the player a certain part belongs too.
    for _, player in ipairs(game.Player:GetPlayers()) do  -- iterate over player
        if part:IsDescendantOf(player.Character) then  -- If the part is within the player's character
            return player  -- return the player
        end
    end
end
door.Touched:connect(function(part)  -- If it isn't a character that touch the door, then we will ignore it.
    local player = get_player(part)
    if not player then return end

    local allow = (game.CreatorId == player.userID)
    if allow then
        open()
        delay(4, close)
    end
end)

Guys please help!

0
I found that i the local allow part I had Id as ID but that still didn't fix it. Bangels8 0 — 10y

2 answers

Log in to vote
1
Answered by 10 years ago

Here ya go. This script does both. But only works with T-Shirts not Gamepasses



print ("VIP T-Shirt Door Script Loaded") permission = { "yzeerf1313" } --Put who ever you want to go through the door without the T shirt -- TextureId of the VIP shirt. texture = "" -- Put the asset of the t shirt here. The whole link function checkOkToLetIn(name) for i = 1,#permission do if (string.upper(name) == string.upper(permission[i])) then return true end end return false end local Door = script.Parent function onTouched(hit) print("Door Hit") local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil ) then if human.Parent.Torso.roblox.Texture == texture then --the shirt Door.Transparency = 0.7 Door.CanCollide = false wait(4) -- this is how long the door is open Door.CanCollide = true Door.Transparency = 0 print("Human touched door") elseif (checkOkToLetIn(human.Parent.Name)) then print("Human passed test") Door.Transparency = 0.7 Door.CanCollide = false wait(0.3) -- this is how long the door is open Door.CanCollide = true Door.Transparency = 0 else human.Health = 0 end end end script.Parent.Touched:connect(onTouched)
0
Just people I want but right now I plan to just be me so thats why I have the "local allow = (game.CreatorId == player.userId)" part in there right now Bangels8 0 — 10y
Ad
Log in to vote
0
Answered by
LevelKap 114
10 years ago

wow that's super complicated above. I recommend making a table

Vip = {"Insertnamehere","ETC","ETC"}

function isPlayerVip(name) for i, v in pairs do if name == v then -- do stuff here like make the door uncancollide or whatever else -- break their joints or whatever you want end end end

Answer this question