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

Why doesn't this t Shirt script work correctly?

Asked by 7 years ago
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=1358153"
local shirt3 ="http://www.roblox.com/asset/?id=1565203"

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)

I am wearing the (1565203) id, but it still says that I'm not wearing the right tshirt

0
It's early for me which is why I am not posting this as an answer but a comment. If this is a gui (which it looks like it) you need to use script.Parent.Sen2.MouseButton1Down:connect(onTouched) when you call the function. yut640 91 — 7y
0
no its not a gui UnleashedGamers 257 — 7y
0
it runs the function, not correctly though UnleashedGamers 257 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

This is what I came up with, and I hope it solves your problem.

First, I changed all of your FindFirstChild'arg' to FindFirstChild("arg"), I'm not sure it made a difference in anything though.

Next, I shortened your shirt IDs, also does nothing except make things look nicer.

And also, what may have been causing the problem: your elseif statement thought that if the player wasn't wearing all three of the shirts, it should execute.

local sen2 = script.Parent.Sen2
-- local link = game:GetService("BadgeService") -- Disabled this, because there's no reason to have it.
-- If the script is still broken, try re-enabling it, I might have broken it again by doing this.

--//

local shirt = "rbxassetid://1645743"
local shirt2 = "rbxassetid://1358153"
local shirt3 ="rbxassetid://1565203"

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

function onTouched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local human = hit.Parent:FindFirstChild("Humanoid")
        local pla = game.Players:GetPlayerFromCharacter(hit.Parent)
        --//Shirt1
        if human.Parent:FindFirstChild("Shirt Graphic", true) 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
            else
                sc.re.Visible = false
                sc.fa.Text = "no"
                sc.fa.Visible = true
            end
        end
    end
end

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

If my solution solved your problem, leave me an upvote and accept my answer. Thanks!

0
Still posts "no" even though I am wearing one of the tshirts UnleashedGamers 257 — 7y
0
Are you sure you sure the IDs are correct? RiftTalon 98 — 7y
Ad

Answer this question