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

Why does this shirt and pants giver script not work when I play it in the actual game?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Well I've been trying to figure out why this script is working in Roblox Studio but not when I play the actual game.

local face = script.Parent.Decal

function GiveFace(Ontouch)
    local hit = Ontouch.Parent:FindFirstChild("Humanoid")
    if hit ~= nil then
        hit.Parent.Head.face.Texture = face.Texture
    end
end
script.Parent.Touched:connect(GiveFace)

^^^ that script works but it is necessary for the other scripts

local shirt = script.Parent.Shirt

function GiveFace(Ontouch)
    local hit = Ontouch.Parent:FindFirstChild("Humanoid")
    if hit ~= nil then
        hit.Parent.Shirt.ShirtTemplate = shirt.ShirtTemplate
    end
end
script.Parent.Touched:connect(GiveFace)

^^^ this script doesn't work

local pants = script.Parent.Pants

function GiveFace(Ontouch)
    local hit = Ontouch.Parent:FindFirstChild("Humanoid")
    if hit ~= nil then
        hit.Parent.Pants.PantsTemplate = pants.PantsTemplate
    end
end
script.Parent.Touched:connect(GiveFace)

^^^ and also this one doesn't work

0
Put it in a code block, NOBODY can read that ._. obcdino 113 — 9y
0
@obcdino sorry i'm kinda new to this lce_bear 31 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Have you tried using WaitForChild?

hit.Parent.Pants.PantsTemplate = pants.PantsTemplate

Instead try...

hit.Parent:WaitForChild("Pants").PantsTemplate = pants.PantsTemplate
Ad

Answer this question