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

Check multiple tshirts instead of 1?

CURRENT SCRIPT :

local sen2 = script.Parent.Sen2
local link = game:GetService("BadgeService")

--//

local shirt = "http://www.roblox.com/asset/?id=1645743"

local sc = script.Parent.Screen.SurfaceGui.Frame

function onTouched(hit)
    local human = hit.Parent:FindFirstChild'Humanoid'
	local pla = game.Players:GetPlayerFromCharacter(hit.Parent)
    if human then
	--//Shirt1
        if hit.Parent:FindFirstChild'Shirt Graphic' then
            if hit.Parent["Shirt Graphic"].Graphic == shirt then
				sc.fa.Visible = false
				sc.re.Text =  "yes"
                sc.re.Visible = true
                elseif hit.Parent["Shirt Graphic"].Graphic ~= shirt then
				sc.re.Visible = false
				sc.fa.Text = "no"
               	sc.fa.Visible = true

            end
        end
    end
end

script.Parent.Sen2.Touched:connect(onTouched)


As you can see here I only am checking 1 tshirt in the script at the moment, how can I change this so I can have possibly a folder of number values that consist of tshirt IDs, and it goes through checking them all seeing if the player is wearing at least one of the real tshirt it prints "yes"

2 comments

0

I would just use a table of shirt IDs and loop though them to see if a player has that item.

0

What type of loop?

1 answer

Well, like I said before, I personally this isnt a very professional way of checking a person wearing a tshirt, but since the script works I guess you can keep it.

local sen2 = script.Parent.Sen2
local link = game:GetService("BadgeService")

--//

local shirt = "http://www.roblox.com/asset/?id=1645743"
local shirt2 = "http://www.roblox.com/asset/?id=IDHERE"
local shirt3 ="http://www.roblox.com/asset/?id=IDHERE"

local sc = script.Parent.Screen.SurfaceGui.Frame

function onTouched(hit)
    local human = hit.Parent:FindFirstChild'Humanoid'
    local pla = game.Players:GetPlayerFromCharacter(hit.Parent)
    if human then
    --//Shirt1
        if hit.Parent:FindFirstChild'Shirt Graphic' then
            if hit.Parent["Shirt Graphic"].Graphic == shirt or hit.Parent["Shirt Graphic"].Graphic == shirt2 or hit.Parent["Shirt Graphic"].Graphic == shirt3 then --basically just checks if the texture == any of the shirt variables.
                sc.fa.Visible = false
                sc.re.Text =  "yes"
                sc.re.Visible = true
                elseif hit.Parent["Shirt Graphic"].Graphic ~= shirt or hit.Parent["Shirt Graphic"].Graphic ~= shirt2 or hit.Parent["Shirt Graphic"].Graphic ~= shirt3  then
                sc.re.Visible = false
                sc.fa.Text = "no"
                sc.fa.Visible = true

            end
        end
    end
end

script.Parent.Sen2.Touched:connect(onTouched)

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