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

What's wrong with my script?

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

✓ Accepted answer

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)

2 comments

0

Will this script remove the hats if I added it to the beggining or will it have to be seperate

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)

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

hat.Parent = c

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