local name = script.Name
gun=game:GetService("DataStoreService"):GetDataStore(name)
function SaveGun(player)
gun:SetAsync(player.userId, player.gunloadout.GunName.equippedGun.Value)
print("Owned guns saved!")
end
function LoadGun(player)
local Gunny = gun:getAsync(player.userId)
if gun ~= nil then
player.gunloadout.GunName.equippedGun.Value = Gunny -- Error happens here, it does not take "gunloadout" as a valid member
end
end
function onPlayerEntered(newPlayer)
if newPlayer:FindFirstChild("GunsSavingData") == nil then
local folder = Instance.new("Folder")
folder.Name = "GunsSavingData"
folder.Parent = newPlayer
end
gunloadout = newPlayer:WaitForChild("GunsSavingData") -- Gunloadout
local GunName = Instance.new("Folder", gunloadout)
GunName.Name = name
local equippedGun = Instance.new("IntValue", gunloadout)
equippedGun.Name = "HasValue"
equippedGun.Value = "1"
local children = script:GetChildren()
for i = 1,#children do
local c = children[i]:clone()
c.Parent = GunName
end
GunName.Parent = gunloadout
equippedGun.Parent = GunName
gunloadout.Parent = newPlayer
newPlayer:WaitForDataReady()
LoadGun(newPlayer)
end
function onPlayerRemoving(player)
print("Attempting to save score for " .. player.Name)
SaveGun(player)
end
COMMUNITY QUESTION
[Solved] Not a valid member of player error?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
are you sure that gunloadout's parent is the player?
In local server test, it shows as it is https://gyazo.com/d5472c982666bb058a30e83294ac5984
Can I see the whole player tree?
Sure, https://gyazo.com/9a589a4dbcaf399cc0f5d06fe202c8b6
It should be player.GunsSavingData OOF
It made an error bcs you defined gunsloadout after you used it....
Oh man, now I feel stupid. Thanks for helping me!
add [SOLVED] in the title