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

How to get the handle into a hat?

local meshes = replicatedstorage:WaitForChild("Classes")
local knight = meshes:WaitForChild("Knight")
local handle = knight:WaitForChild("Handle")
		
local hat = Instance.new("Hat")
handle:Clone().Parent = hat
hat.Handle.FormFactor = "Custom"
hat.Handle.Size = Vector3.new(0.2,0.2,0.2)
hat.Handle.Anchored = false
hat.Parent = player.Character

--[[
My attempt at making the handle move down relative to the current position

hat.Handle.Position = Vector3.new(0,-2,0)

But that did nothing to the handle, with or without that piece of code
--]]

The script works, but not 100% how I want it to work. First, it creates the hat inside the character, but when it does, it deletes the handle inside the hat, BUT the handle is still visible on the player.

Secondly I want to be able to move the handle down a little bit, but I have tried looking around the wiki with how to move the handle relative to it's current position, and although I found a wiki on it, I tried putting it into the model but it didn't work.

Their are no errors in the output either.

EDIT I just did a test, and if I make the hats parent workspace, then it creates like 10000 hats in workspace. Why is it constantly creating hats??

The script is not inside a loop either, it's just a function with only that code inside it.

1 answer

✓ Accepted answer

To move the hat, you have to use AttachmentPos property of Hat and play with the values until you get what you wanted.

local hat = Instance.new("Hat")
hat.Parent = player.Character
hat.AttachmentPos = Vector3.new(0,0,0) -- Put values here

local handle = handle:Clone() -- Use a variable instead of referencing the handle multiple times
handle.Parent = hat
handle.Name = 'Handle'

handle.FormFactor = "Custom"
handle.Size = Vector3.new(0.2,0.2,0.2)
handle.Anchored = false

And for the hat cloning, it depends. Where is this script and is this the full code?

4 comments

0

It is named Handle

0

Oh, sorry, I missed that somehow.

0

Got it working thanks!

0

No problem. :)

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