Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Getting hats from server storage?

Asked by 9 years ago

(This is a normal script, not local)

local p = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent
local c = p.Character
script.Parent.MouseButton1Up:connect(function()
if p.leaderstats.Lvl.Value >= 60 then 
local d = c:GetChildren()
for i=1, #d do
if d[i].className == "Hat" then
d[i]:remove()
end
end
print 'Hats Removed'
wait()
local ha = Instance.new("Hat")
ha.AttachmentForward= Vector3.new(-0, -0, -1)
ha.AttachmentPos = Vector3.new(0, 1.64, -0.01)
ha.AttachmentRight = Vector3.new(1, 0, 0)
ha.AttachmentUp = Vector3.new(0, 1, 0)
game.ServerStorage:WaitForChild("DemonHood")
b = a:GetChildren()
for i=1, #b do
b[i].Parent = ha 
end
ha.Parent = c 
print 'Hat Added'
end
end)
print 'Hat Added'

It prints 'Hat Added' but nothing happens

0
Not that this is a big deal, but :remove() is depreciated. :destroy() is the upgraded version of this method. Legojoker 345 — 9y

1 answer

Log in to vote
0
Answered by
Legojoker 345 Moderation Voter
9 years ago

This script's oldest traceable ancestor is from the Jurassic era; jokes aside, the variable "a" is never defined. This probably causes the script to error because you are getting children from a nil object. I'm guessing you wanted it to be local a = game.ServerStorage:WaitForChild("DemonHood")

0
It's still printing out correctly but not giving the hat. DrChowderr 0 — 9y
0
Ask the script to print the name of p --print(p.Name)-- and check to see if that userdata is actually correct. Legojoker 345 — 9y
Ad

Answer this question