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

Check multiple tshirts instead of 1?

Asked by 7 years ago

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"

0
I would just use a table of shirt IDs and loop though them to see if a player has that item. User#11440 120 — 7y
0
What type of loop? UnleashedGamers 257 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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)
Ad

Answer this question