Custom hats for your team create player

Hello there, everyone! I just wanted to give everybody here access to my plugin that gives accessories to your team create player/camera.

How It Works

First, you have to install the plugin.

After you have installed it and clicked on it in studio, you will see this interface:

The Asset ID part is quite self-explanatory, but the offset can get pretty confusing, so I’ll try my best to explain it.

You should format your offset like this: x, y, z
X is how far left or right to the player it will be (positive value being right and negative being left)
Z is how far forward or backwards from the player it will be (positive being in front and negative being behind)
Y is how far up or down from the player it will be (positive being up and negative being down)

Here is an example of the plugin in action:

Have fun! and if you have any questions, leave them below!

And also here is the code for anybody wondering how it works:

local plr = game.Players.LocalPlayer
local item
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local tb = plugin:CreateToolbar("Custom Team Create Hat")

local newhat = tb:CreateButton("Create New Hat", "Create New Hat", "http://www.roblox.com/asset/?id=10164183611")
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, true, 300, 200)

local dragSourceWidget = plugin:CreateDockWidgetPluginGui("Customization", widgetInfo)
newhat.ClickableWhenViewportHidden = true
local testButton = Instance.new("TextButton")
testButton.BorderSizePixel = 0
testButton.TextSize = 20
testButton.TextColor3 = Color3.new(0.32549, 0.32549, 0.32549)
testButton.AnchorPoint = Vector2.new(0.5, 0.5)
testButton.Size = UDim2.new(1, 0, 0.1, 0)
testButton.Position = UDim2.new(0.5, 0, 0.1, 0)
testButton.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton.Text = "Clear All Hats"
testButton.Parent = dragSourceWidget

local testButton2 = Instance.new("TextBox")
testButton2.BorderSizePixel = 0
testButton2.TextSize = 20
testButton2.TextColor3 = Color3.new(0.32549, 0.32549, 0.32549)
testButton2.AnchorPoint = Vector2.new(0.5, 0.5)
testButton2.Size = UDim2.new(1, 0, 0.1, 0)
testButton2.Position = UDim2.new(0.5, 0, 0.3, 0)
testButton2.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton2.Text = "Hat ID"
testButton2.Parent = dragSourceWidget

local offset = Vector3.new(0,0,0)

if not game:GetService("RunService"):IsRunning() then


else
	for i,v in pairs(workspace.Terrain:GetChildren()) do
		v:Destroy()
	end
end


local testButton3 = Instance.new("TextBox")
testButton3.BorderSizePixel = 0
testButton3.TextSize = 20
testButton3.TextColor3 = Color3.new(0.32549, 0.32549, 0.32549)
testButton3.AnchorPoint = Vector2.new(0.5, 0.5)
testButton3.Size = UDim2.new(1, 0, 0.1, 0)
testButton3.Position = UDim2.new(0.5, 0, 0.5, 0)
testButton3.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton3.Text = "Custom Offset (Vector3)  Format: x, y, z"
testButton3.Parent = dragSourceWidget
testButton3.TextScaled = true
testButton3.FocusLost:Connect(function(ep)
	if ep then
		if testButton3.Text:match("(.+), (.+), (.+)") or testButton3.Text:match("(.+),(.+),(.+)") then
			
			if testButton3.Text:match("(.+), (.+), (.+)") then
				offset = Vector3.new(testButton3.Text:match("(.+), (.+), (.+)"))
			else
				offset = Vector3.new(testButton3.Text:match("(.+),(.+),(.+)"))
			end
			
			
			print(offset)
		end
	end
end)

testButton.MouseButton1Down:Connect(function()
	for i,v in pairs(game.Workspace.Terrain:GetChildren()) do
		if v.Name == plr.Name .. "'s hat" then
			v:Destroy()
		end
	end
end)


testButton2.FocusLost:Connect(function(ep)
	if ep then
		if tonumber(testButton2.Text) then
			local id = tonumber(testButton2.Text)
				local insertserv = game:GetService("InsertService")
				item = insertserv:LoadAsset(id)	
				item.Parent = workspace.Terrain
				item.Name = plr.Name .. "'s hat"
			local handle : BasePart = item:FindFirstChildOfClass("Accessory").Handle
				handle.LocalTransparencyModifier = 0.5
				game.Players.PlayerRemoving:Connect(function(p)
					if p == plr then
						item:Destroy()
					end
				end)
				while task.wait() do
					if game:GetService("RunService"):IsStudio() then
					item:FindFirstChildOfClass("Accessory").Handle.CFrame = workspace.Camera.CFrame + workspace.Camera.CFrame.UpVector * offset.Y + workspace.Camera.CFrame.LookVector * -offset.Z + workspace.Camera.CFrame.RightVector * offset.X

					else
						item:Destroy()
					end
				end
		end
	end
end)

newhat.Click:Connect(function()
	dragSourceWidget.Enabled = true
	
end)

(sorry if its messy)

2 Likes

Truly wonderful.

This is essential for Team game development.

1 Like