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

Cannot find texture ID player is wearing?

Asked by 6 years ago

Hi,

I am attempting to operate a t-shirt/shirt only door at which only operates when someone has the correct clothing on. I think this is the older way of performing the task of collecting the texture ID that someone is wearing and wanted to know the new way to get this to work? The links there are correct so it's just helping the script find the texture the player is wearing?

print ("VIP T-Shirt Door Script Loaded")


permission = { "kieranm9090" } 


first = "http://www.roblox.com/asset/?version=1&id=412190047" 
premiumeco = "http://www.roblox.com/asset/?version=1&id=412190012"



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 == first or premiumeco then 
            Door.Transparency = 1 
            Door.CanCollide = false
            wait(4)  
            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(4) 
            Door.CanCollide = true 
            Door.Transparency = 0  
        end 
    end 
end 

script.Parent.Touched:connect(onTouched)

Many thanks, Kieran

1 answer

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

Instead of 'or', you have to separate 'first' and 'premiumco' from each other and give them their own statement.

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 == first then 
           openDoor()

    elseif human.Parent.Torso.roblox.Texture == premiumeco then 
        openDoor()

        elseif (checkOkToLetIn(human.Parent.Name)) then 
            print("Human passed test") 
            Door.Transparency = 0.7
            Door.CanCollide = false 
            wait(4) 
            Door.CanCollide = true 
            Door.Transparency = 0  
        end 
    end 
end 

function openDoor()
     Door.Transparency = 1 
            Door.CanCollide = false
            wait(4)  
            Door.CanCollide = true 
            Door.Transparency = 0 
        print("Human touched door") 
end
Ad

Answer this question