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

[Solved] Accesory is not a valid member of serverstorage?

Asked by 5 years ago
Edited 5 years ago

So i was working on a hatgiver server script. When the player hits the script parent it gives the player An accesory(AngelWings)

Wait(3) 
Script.Parent.Touched:Connect(function(hit)
If hit. Parent:FindFirstChild("humanoid") then
workspace.(myplayername).Humanoid:AddAccessory(game.ServerStorage.AngelWings)
end
end) 

It works well but after i reset my character or if i die it doesnt work heres the output

AngelWings is not a valid member of ServerStorage
1
Shouldn't you use clone? TypicallyPacific 61 — 5y
1
The error explains itself? User#5423 17 — 5y
0
I mean it works before i reset character Zheercombater1 -1 — 5y

2 answers

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago

This is working before reseting, but not after, cause the :AddAccessory() function changes he parent of the accessory, so logiclly, the accessory that was stored in server storage is no longer there because we changed its parent, and accessories that are not parented to the player after running the game won't stay there after dying, now what you gotta do is use the :Clone() function, now this is useful it will make a copy of the instance put in its argument, and like that you're original will stay there and there's no problem with loosing the copy. Also you're script had a ton of problems such as the (myplayername) thing, how will that work? since each player has a different name how will you do that, this is a situation you're always gonna meet, so pay attention, hit is refering to the player's body parts, thenn doing hit.Parent:FindFirstChild is refering to the player that touched's humanoid.

So this is probarly your script

wait(3) 
local accessory = game:GetService("ReplicatedStorage").AngelWings:Clone() 
-- this is how you gotta use :Clone
script.Parent.Touched:Connect(function(hit)
    if hit. Parent:FindFirstChild("humanoid") then
        workspace.(myplayername).Humanoid:AddAccessory(accessory)
    end
end) 
0
Thanks it worked i know my script was a mess because i was just working on it Zheercombater1 -1 — 5y
0
its go! always practice. starmaq 1290 — 5y
0
ok* starmaq 1290 — 5y
Ad
Log in to vote
0
Answered by
CodyDev 70
5 years ago

It doesn't work after you reset because you already used it and it's gone after it's on your character.

wait(3)
script.Parent.Touched:Connect(function(hit)
    if(hit.Parent:FindFirstChild("Humanoid")) then
        hit.Parent.Humanoid:AddAccessory(game.ServerStorage.AngelWings:Clone())
    end
end)

This script clones the wings and uses that clone to put on your character so you never "run out" of them.

0
Thanks for your answer but this doesnt work it doesnt clone the wing Zheercombater1 -1 — 5y
0
That is the method I use to clone things and it works for me but ok then. CodyDev 70 — 5y

Answer this question