iPremiumZJoin Date: 2012-01-23 Post Count: 6834 |
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. |
|
|
iPremiumZJoin Date: 2012-01-23 Post Count: 6834 |
|
|
|
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. |
|
|
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) |
|
iPremiumZJoin Date: 2012-01-23 Post Count: 6834 |
^ Doesn't work... |
|
|
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. |
|
iPremiumZJoin Date: 2012-01-23 Post Count: 6834 |
Ok, it's broken, won't subtract money or give you the hat... |
|
joeymeJoin Date: 2009-10-11 Post Count: 530 |
Does the script know what plyr is? |
|
|
Mind to post the output, then? |
|
|
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.
|
|
|
@Ravenshield
It might be. I was waiting for him to give us the output so we can finally know what the error actually is. |
|
iPremiumZJoin Date: 2012-01-23 Post Count: 6834 |
No output X_X |
|
joeymeJoin Date: 2009-10-11 Post Count: 530 |
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. |
|