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

How would I make a team spawn with a hat on?

Hello, I'm making a game that's SCP:F Based, and I'm wondering how I can give a team a Classic Fedora when they spawn. Please respond with any answers.

Thanks, Rook.

1 answer

This script makes it so certain teams have certain hats.

team1 = "Bright red"

--------------------------------- EDIT THESE 2 TEAMS AS YOU WANT, BUT KEEP 1ST RED AND 2ND BLUE!

team2 = "Bright blue"

game.Players.PlayerAdded:connect(function(player)

--[[player.Changed:connect(function(v)

for i, o in pairs(v) do

if v == 'TeamColor' then

player:LoadCharacter()

end end

end)]]

player.CharacterAdded:connect(function(char)

wait(1)

a = char:GetChildren()

for i =1 ,#a do

if a[i].ClassName == 'Hat' then

a[i]:remove()

end

end

wait(0.5)

if player.TeamColor == BrickColor.new(team2) then

local Hat = Instance.new("Hat")

Hat.Name = "HATNAMEHERE"

Hat.AttachmentForward = Vector3.new(0, 0, 1)

Hat.AttachmentPos = Vector3.new(-0.200000003, -0.300000012, 0.200000003)

Hat.AttachmentRight = Vector3.new(1, 0, 0)

Hat.AttachmentUp = Vector3.new(0, 1, 0)

local Handle = Instance.new('Part')

Handle.Size = Vector3.new(3.6, 3.4, 3.6)

Handle.Anchored = false

Handle.Locked = true

Handle.CanCollide = true

local m = script.Mesh3:Clone()

m.Parent = Handle

Handle.Name = "Handle"

Handle.Parent = Hat

Hat.Parent = char

elseif player.TeamColor == BrickColor.new(team1) then

local h = Instance.new("Hat")

local p = Instance.new("Part")

h.Name = "Hat" -- It doesn't make a difference, but if you want to make your place in Explorer neater, change this to the name of your hat.

p.Parent = h

p.Position = char:FindFirstChild("Head").Position

p.Name = "Handle"

p.formFactor = 0

p.Size = Vector3.new(-0,-0,-1)

p.BottomSurface = 0

p.TopSurface = 0

p.Locked = true

script.Mesh1:clone().Parent = p

h.Parent = char

h.AttachmentPos = Vector3.new(-0.2, -0.3, 0.2)

elseif player.TeamColor ~= BrickColor.new(team1) and player.TeamColor ~= BrickColor.new(team2) then

local Hat = Instance.new("Hat")

Hat.Name = "OTHERTEAMHATNAMEHERE"

Hat.AttachmentForward = Vector3.new(0, 0, 1)

Hat.AttachmentPos = Vector3.new(0, -0.300000012, 0.200000003)

Hat.AttachmentRight = Vector3.new(1, 0, 0)

Hat.AttachmentUp = Vector3.new(0, 1, 0)

local Handle = Instance.new('Part')

Handle.Size = Vector3.new(3.6, 3.4, 3.6)

Handle.Anchored = false

Handle.Locked = true

Handle.CanCollide = true

local m = script.Mesh2:Clone()

m.Parent = Handle

Handle.Name = "Handle"

Handle.Parent = Hat

Hat.Parent = char

end

end)

end)``

2 comments

0

-1 and unaccepting for giving bad code, spoon feeding.

0

you could just tell me to delete it. no need to harm me

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