generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Hat GUI Giver gives hats wrong

Previous Thread :: Next Thread 
AsianProperty is not online. AsianProperty
Joined: 23 Jul 2010
Total Posts: 919
16 Aug 2016 12:06 PM
This function when given the right information needed to run will run correctly and place the hat itself within the player and in studio it looks fine, but within a Roblox server it places the hats on the players neck, does anybody know how to fix this This must universally work with all hats that are attached to the head so wings/swords are not included.

function purchaseHat(itemId)
hatModel = game:GetService("InsertService"):LoadAsset(itemId)
hatTable = hatModel:GetChildren()
print(hatTable[1].Name)
hat = hatModel:FindFirstChild(hatTable[1].Name)
--print(hatModel.Name)
--print(hat.Name)
hatModel.Parent = player.Character
hat.Parent = player.Character
hatModel:Destroy()
--hat.Handle.Position = player.Character:FindFirstChild("Head").Position
hat.Handle.Locked = true
--[[
hat.AttachmentForward = Vector3.new (-0, -0, -1)
hat.AttachmentPos = Vector3.new(0, 0.4, 0)
hat.AttachmentRight = Vector3.new (1, 0, 0)
hat.AttachmentUp = Vector3.new (0, 1, 0)
--]]
weld = Instance.new("ManualWeld")
weld.Parent = hat.Handle
weld.Part0 = hat.Handle
weld.Part1 = player.Character:FindFirstChild("Head")
end


~It's always better in the night
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
16 Aug 2016 12:20 PM
I've seen this before, what you can do to avoid it is anchor the hat and the player's head while you apply the welds, then wait() and then unanchor.

However, since it's truly a hat object, you shouldn't have to apply welds at all, just parenting the hat to the character should be enough.


Report Abuse
AsianProperty is not online. AsianProperty
Joined: 23 Jul 2010
Total Posts: 919
16 Aug 2016 12:23 PM
I actually just solved it by deprecated the weld, once the hat is within the player it automatically attaches to their head correctly and the weld would weld it dead center on the head.


~It's always better in the night
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image