game.Players.PlayerAdded:Connect(function(Player) Player.Backpack:FindFirstChild("Oddity").Value = game.ServerStorage.Odditys.Oddity1 if Player.Backpack:FindFirstChild("Oddity").Value == game.ServerStorage.Odditys.Oddity1 or game.ServerStorage.Odditys.Oddity2 then local Oddity = Player.Backpack.Oddity.Value Oddity:Clone().Parent = Player.Backpack end end)
ERROR = ServerScriptService.DataService:3: attempt to index nil with 'Value' line = 3 the value is an object value
This is because you are using .Value
but the :FindFirstChild("Oddity")
may not find Oddity and therefore it returns nil. It's the same as saying nil.Value
hence the error.
To fix this you should try :FindFirstChild()
and on the next line check if it wasn't nil
game.Players.PlayerAdded:Connect(function(Player) local oddity = Player.Backpack:FindFirstChild("Oddity") if oddity then -- check if it's not nil then move on oddity.Value = game.ServerStorage.Odditys.Oddity1 if oddity.Value == game.ServerStorage.Odditys.Oddity1 then -- whatever end else warn("Could not find Oddity in player backpack") end end)