of     1   

iPremiumZ
#63867735Monday, March 05, 2012 1:18 PM GMT

function MB1D() if plyr.Coins.Value >= 5 then plyr.Coins.Value = plyr.Coins.Value - 5 plyr = script.Parent.Parent.Parent.Parent p = game:GetService("InsertService"):LoadAsset(tonumber(script.Parent.Name)) p.Parent = workspace p:makeJoints() d = plyr.Character:getChildren() for i = 1,#d do if d[i].className=="Hat" then d[i].Parent = nil end end c = p:getChildren() for i = 1,#c do c[i].Parent = plyr.Character end p.Parent = nil end end script.Parent.MouseButton1Down:connect(MB1D) The parent's name is the ID of the hat.
JulienDethurens
#63867788Monday, March 05, 2012 1:22 PM GMT

iPremiumZ
#63867839Monday, March 05, 2012 1:26 PM GMT

Please stop following me around with pointless replies: http://www.roblox.com/Forum/ShowPost.aspx?PostID=62527562
JulienDethurens
#63867897Monday, March 05, 2012 1:30 PM GMT

Wasn't actually following you around. :P Now, I remember why I recognize your name, though. Also, my reply isn't pointless. You just posted code expecting us to fix it or make it do something else, we don't even know if it's actually broken or just doesn't do what you want it to do.
JulienDethurens
#63868001Monday, March 05, 2012 1:39 PM GMT

Cleaned up the code a little: script.Parent.MouseButton1Click:connect(function()    if plyr.Coins.Value >= 5 then       plyr.Coins.Value = plyr.Coins.Value - 5       plyr = script.Parent.Parent.Parent.Parent       local asset = game:GetService('InsertService'):LoadAsset(tonumber(script.Parent.Name))       if #(asset:GetChildren()) == 0 then return end       asset:MakeJoints()       for _, child in next, plyr.Character:GetChildren() do          if child:IsA('Hat') then             child:Destroy()          end       end       for _, child in next, asset:GetChildren() do          child.Parent = plyr.Character       end end)
iPremiumZ
#63868233Monday, March 05, 2012 1:53 PM GMT

^ Doesn't work...
JulienDethurens
#63868364Monday, March 05, 2012 2:03 PM GMT

I never said it works, I just said I cleaned up the code. I don't want to bother fixing a script if the author doesn't even bother to actually give some info.
iPremiumZ
#63868621Monday, March 05, 2012 2:21 PM GMT

Ok, it's broken, won't subtract money or give you the hat...
joeyme
#63868661Monday, March 05, 2012 2:23 PM GMT

Does the script know what plyr is?
JulienDethurens
#63868747Monday, March 05, 2012 2:28 PM GMT

Mind to post the output, then?
Ravenshield
#63868854Monday, March 05, 2012 2:37 PM GMT

Wait.. if plyr.Coins.Value >= 5 then plyr.Coins.Value = plyr.Coins.Value - 5 plyr = script.Parent.Parent.Parent.Parent <--- ?? That means plyr isn't specified for the lines above.
JulienDethurens
#63868938Monday, March 05, 2012 2:44 PM GMT

@Ravenshield It might be. I was waiting for him to give us the output so we can finally know what the error actually is.
iPremiumZ
#63869106Monday, March 05, 2012 2:55 PM GMT

No output X_X
joeyme
#63889965Tuesday, March 06, 2012 12:04 AM GMT

function Clicked() plyr = script.Parent.Parent.Parent.Parent if plyr.Coins.Value >= 5 then plyr.Coins.Value = plyr.Coins.Value - 5 p = game:GetService("InsertService"):LoadAsset(tonumber(script.Parent.Name)) p.Parent = workspace p:makeJoints() d = plyr.Character:getChildren() for i = 1,#d do if d[i].className=="Hat" then d[i].Parent = nil end end c = p:getChildren() for i = 1,#c do c[i].Parent = plyr.Character end p.Parent = nil end end script.Parent.MouseButton1Down:connect(Clicked) --Make sure you put this script inside the button.

    of     1