player = game.Players.LocalPlayer
cost = 500
function checkForColt()
found = false
for i, v in pairs(player.Backpack:GetChildren()) do
if v.Name == "Colt" then
found = true
end
end
for i, v in pairs(player.Humanoid:GetChildren()) do -- This is where the error is
if v.Name == "Colt" then
found = true
end
end
if found then
return true
else
return false
end
end
script.Parent.MouseButton1Click:connect(function()
leaderstats= player:FindFirstChild("leaderstats")
if leaderstats then
Money = leaderstats:FindFirstChild("Money")
if Money then
hasColt = checkForColt()
if Money.Value >= cost and not hasColt then
Money.Value = Money.Value - cost
NewGun = game.ReplicatedStorage.Colt:Clone()
NewGun.Parent = game.Players.LocalPlayer.Backpack .
end
end
end
end)
The error read's Humanoid is not a valid member of Player. I've tried Charater too, with no such luck. +10 cookiez if you get it right?

1 comment
The 'Humanoid' I found WITHIN the Player's Character, but, sometimes the code executes BEFORE the Character has spawned, but, if it is saying for the Humanoid when you do 'Character', then that means 'Humanoid' was not existant at the time of execution. Consider using the 'WaitForChild' method?