CoreScript Hat Dropper (=)

I said I would sign off there but you know what scratch that.

You can simply enable the collisions of the handle, reparent the handle to workspace, and destroy the accessory instance

1 Like

Oh wait you just gave me an idea. I can just make the hats invisible once you press ‘=’ then clone the hats after its been parented to workspace + anchored then just drop the handle itself in the same position where it was anchored

1 Like

Although I would like to know the actual cframe of it all cause I want something accurate without having to guess the cframe. I can only get it as close to it as possible

I do wonder, could the Accessory’s properties have something to do with its cframe?

1 Like

There was no CFrame, see this:

This behavior is automatic and should still work to this day; there is no CoreScript for it, it’s built into the engine itself.

4 Likes

And here’s a gif proving that you don’t need a CFrame, or any advanced scripting to achieve this. This 100% does work to this day:

All you need to do is set the Accessories parent to Workspace. That’s it. No further code is required to achieve the old school functionality.

Important Edit:
I just tested, and this does not work if you parent the Accessory to a Folder, or Model.
It must be directly parented to game.Workspace

Cheers, hope this helps you get the behavior your looking for!

Edit 2:
If you need the accessory to be somewhere else other than Workspace, try this:

local RunService = game:GetService("RunService")

function GetRidOfHat(Accessory)
	Accessory.Parent = game.Workspace
	RunService.Heartbeat:wait() -- wait one tick to allow engine to move hats
	Accessory.Parent = game.Workspace.SomeInstanceWhereINeedHatsToGo
end
2 Likes

Maybe if you can explain your use case for needing this we can help you better as we don’t appear to know the code roblox used for this behaviour although feel free to look through the opensource code yourself. If it’s simply to get hats to drop on =, Roblox provided a workaround script that @incapaxx pointed out, This parents the hat to the workspace and as TheGamer101 Roblox Staff explained, when an accessory is dropped from player to Workspace the legacy movement still functions of it poping off you and laying nearby.

1 Like

Parent the hat to workspace to “drop” it.

1 Like

Hey, I have the code right here. Make sure to mark this as a solution if it is what you were looking for so other people know that this has been solved.

CODE:

local Players    = game:GetService("Players");
local UserInput  = game:GetService("UserInputService");

local Player     = Players.LocalPlayer;
local Character  = Player.Character;

UserInput.InputBegan:Connect(function(keyPressed)
    if (keyPressed.KeyCode == Enum.KeyCode.Equals) then
        for index, value in next, Character:FindFirstChildOfClass("Humanoid"):GetAccessories() do
            value.Parent = workspace;
            print(value.CFrame) -- Cframe
        end;
    end;
end);

Thank you tho but please explain to me why are the accessories positioning in front of you when parented to workspace as opposed to parenting to something else within workspace. If it only positions like that when its only parented to workspace, it seems to me something behind the scenes is detecting accessories added to workspace and changing its position. I haven’t actually tested that myself but based on what you said, it becomes more clear that the cframe is being changed as it only works if you parent it to workspace.

I understand its the engine but I can’t say this is solved because I’m asking for the actual cframe thats being set behind the scenes. I understand there are other ways of achieving this but I’ve done things like that. I only came to here to ask if anybody knew what that code where that positioning is being handled because I want something accurate without having to do anything hacky or what not. I understand completely what you guys are saying but I came here to ask if somebody knew, it’d be greatly appreciated. Its not really something I really need as I have got something pretty close to the offset position but it would be nice to have something accurate.

I appreciate you all trying to help but I’m only asking for one thing.

1 Like

Yep, this is just how it works. The roblox engine itself checks when a hat is moved from a character, to workspace. Then it offsets the position. Nobody knows what the offset is because it’s built into the engine itself, not a CoreScript. It’s just how hats have always worked on Roblox since the beginning of time.

We can’t really answer this, and engineers likely won’t come tell you what the offset is. TheGamer101 would know, but I don’t think he’ll be here explaining to you how the engine does it.

You can sorta figure this out on your own, by moving the hat to workspace, using RunService.Heartbeat:wait(), anchoring the hat, then checking how far it is from the character. That would be your best bet your figuring it out, nobody here but roblox engineers knows the true answer.

Edit: my question to you is, why do you need to know? Can’t you just parent it to workspace?

This isn’t what the OP is asking for? They want the actual code the Roblox engine itself uses to determine where a hat drops when using this script, specifically the CFrame, as mentioned in previous posts.