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

What's wrong with my script?

Asked by 10 years ago
local shirtemplate = "148302166" -- Took away 1 from the shirt ID
local pantstemplate = "133004168" -- Took away 1 from the pants ID
local hats = {"1029025","hat 2 id","hat 3 id","even a hat 4 id"}

function giveShirtAndPants(p)
    local c = p.Character
    c.Shirt.ShirtTemplate = shirtemplate
    c.Pants.PantsTemplate = shirtemplate
    for _,v in pairs(hats) do
        local hat = game:GetService("InsertService"):LoadAsset(v).Parent = c 
    end
end

game.Players.PlayerAdded:connect(function(p)
    repeat wait() until p ~= nil
    repeat wait() until p.Character ~= nil
    giveShirtAndPants(p)
    p.CharacterAdded:connect(function(c)
        repeat wait() until c ~= nil
        giveShirtAndPants(p)
    end)
end)
-- Line 10 says: 11:55:12.611 - Workspace.Script:10: unexpected symbol near '='

I can't fish out the unexpected symbol near '='

2 answers

Log in to vote
1
Answered by 10 years ago

I fixed it and massively improved the efficiency of it for you:

local ShirtTemp = "148302166"
local PantsTemp = "133004168"
local Hats = {"1029025"}

function giveShirtAndPants(Plr)
    local Char = Plr.Character
    coroutine.resume(coroutine.create(function()
        repeat wait(1/30) until Char:findFirstChild("Shirt")
        Char.Shirt.ShirtTemplate = "http://www.roblox.com/asset?id=" .. ShirtTemp
    end))
    coroutine.resume(coroutine.create(function()
        repeat wait(1/30) until Char:findFirstChild("Pants")
        Char.Pants.PantsTemplate = "http://www.roblox.com/asset?id=" .. PantsTemp
    end))
    for _,v in next, Hats do
        local Hat = game:GetService("InsertService"):LoadAsset(v):GetChildren()[1]
        Hat.Parent = Char
    end
end

game:GetService("Players").PlayerAdded:connect(function(Plr)
    repeat wait(1/30) until Plr ~= nil
    repeat wait(1/30) until Plr.Character ~= nil
    giveShirtAndPants(Plr)
    Plr.CharacterAdded:connect(function(Char)
        repeat wait(1/30) until Char ~= nil
        giveShirtAndPants(Plr)
    end)
end)
0
Will this script remove the hats if I added it to the beggining or will it have to be seperate RFYassine 15 — 10y
0
game.Workspace.ChildAdded:connect(function(obj) if (obj:IsA("Hat")) then wait(4) if (obj.Parent == game.Workspace) then obj:Destroy() end end end) RFYassine 15 — 10y
Ad
Log in to vote
0
Answered by
war8989 35
10 years ago

Try removing .Parent = c on line 10 and on the next line do:

hat.Parent = c

Answer this question