If so, how? I need to remove the weight from players's hats when they enter the server.
Is it possible to remove a hats weight?
1 answer
Weight can be defined as the force that gravitation exerts upon a body, which can further be defined as the mass of an object times the acceleration of gravity. In Roblox the acceleration of gravity is 196.2 studs/second^2 and thus the force of gravity is 196.2*mass of an object. So, what we need to do is to add a counter-force to essentially "remove the weight".
The first step would be determining what objects to apply this force to. We can do so with the following code inside a script that is then located inside of game.StarterPlayer.StarterCharacterScripts.
for i, v in pairs(script.Parent:GetChildren()) do --Loop through all objects in a players character
if v:IsA("Hat") then --Check if the object is a hat
if v:FindFirstChild("Handle") then --Find an object named "Handle" inside of the hat (traditionally inside of hats there is a part titled Handle)
-- Cancel the force of gravity for v.Handle
end
end
end
Now that we have access to the parts we want to negate the force of gravity for all we need to do is actually negate gravity. One way to do so is adding a BodyForce object to it that is equal to the force of gravity. We can do so with the following code:
local bf=Instance.new("BodyForce", v.Handle) --Create a new BodyForce located in v.Handle
bf.Force=Vector3.new(0,196.2*v.Handle:GetMass(),0) --Set the force so that it cancels out gravity
Finally all is left is to combine the previous two blocks of code and put them into your game. Once combined we get:
for i, v in pairs(script.Parent:GetChildren()) do --Loop through all objects in a players character
if v:IsA("Hat") then --Check if the object is a hat
if v:FindFirstChild("Handle") then --Find an object named "Handle" inside of the hat (traditionally inside of hats there is a part titled Handle)
local bf=Instance.new("BodyForce", v.Handle) --Create a new BodyForce located in v.Handle
bf.Force=Vector3.new(0,196.2*v.Handle:GetMass(),0) --Set the force so that it cancels out gravity
end
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You did all that work for a question that's gonna be deleted? Don't try to answer these types of little effort questions because he never tried making the script himself. An explanation on how it works is nice. A whole script is too much.