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

How to get the handle into a hat?

Asked by 8 years ago
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

Log in to vote
1
Answered by 8 years ago

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?

0
It is named Handle NinjoOnline 1146 — 8y
0
Oh, sorry, I missed that somehow. LetThereBeCode 360 — 8y
0
Got it working thanks! NinjoOnline 1146 — 8y
0
No problem. :) LetThereBeCode 360 — 8y
Ad

Answer this question